+ 1

Import random

How to choose one random item in Python between multiple strings? random.randint is for numbers random._______ is for String???

28th Mar 2020, 6:52 AM
Ali Khosroanjam
Ali Khosroanjam - avatar
4 ответов
+ 4
random.choice(iterable) will return a random item from the iterable. if your strings are in an iterable, it should work.
28th Mar 2020, 6:57 AM
John Robotane
John Robotane - avatar
0
what do you mean by multiple string?
28th Mar 2020, 6:56 AM
Muhammad Faheem Nasir
Muhammad Faheem Nasir - avatar
0
2 or 3 or ... string Thanks very much🙌🙌🙌
28th Mar 2020, 7:02 AM
Ali Khosroanjam
Ali Khosroanjam - avatar
0
Are you trying to return a random character from a string or return a random word from a sentence/phrase?
28th Mar 2020, 8:20 AM
rodwynnejones
rodwynnejones - avatar