1

How to make python choose randomly between multiple strings?

0

2 Answers 2

22

Add them all to a list, import random, then call the choice method like so:

In [1]: import random
In [2]: hello = ['hi', 'hello', 'yo', 'bonjour', 'hola', 'salaam']
In [3]: random.choice(hello)
Out[3]: 'bonjour'
Sign up to request clarification or add additional context in comments.

Comments

-3

random.choice() is your friend.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.