python - How can I get user input for an array? -
i want create list user's input , return random value list.
this have far code can't figure out how input array.
import random movie_array = ["moviea", "movieb", "moviec"] print(random.choice(movie_array))
i know input function i'm not sure how use create array/list. tried following didn't work
movie_array = input()
but when run random.choice on selects individual character.
you can this:
>>> import random >>> movie_array = [input("input movie: ") in range(3)] input movie: moviea input movie: movieb input movie: moviec >>> print(random.choice(movie_array)) moviec
Comments
Post a Comment