2
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']

1
  • 2
    random.choice() w/o s. Commented Jan 7, 2022 at 7:40

1 Answer 1

2

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 list as variable name, that's python list constructor
  • shoot is already a string, no need of str()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.