So I need a variable to pick from a list I tried this code and it doesn't work. Any ideas?
list = ["R", "P","S"]
bot = random.choice(list)
CodePudding user response:
Did you import random?
You could manually build it out like so:
import random
def choice(a_list):
return a_list[random.randrange(0,len(a_list)-1)]
print(choice([1,2,3]))
CodePudding user response:
use import random
import random
list = ["R", "P","S"]
bot = random.choice(list)
print(bot)