import random as r
list = ['left','right','center']
shoot = r.choices(list)
print('python says, shoot ' + str(shoot))
How can I get it to output just left or right or center instead of ['left']
>Solution :
The method random.choices make multiples choice, use random.choice
import random as r
values = ['left','right','center']
shoot = r.choice(values)
print('python says, shoot', shoot)
Note
- don’t use
listas variable name, that’s python list constructor shootis already a string, no need ofstr()