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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -