On 2012/02/07 07:40 AM, Michael Lewis wrote:
I want to prompt the user only once to enter 5 numbers. I then want to create a list out of those five numbers. How can I do that?

I know how to do it if I prompt the user 5 different times, but I only want to prompt the user once.

Thanks.

--
Michael



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
You can take your input from your user in one line seperated by something like a space and then split it after you capture it so for eg.

user_input = raw_input('enter 5 numbers seperated by a space each: ')
list_from_input = user_input.split() # Split by default splits on spaces, otherwise you need to specify the delimiter # Then you can validate the list to ensure all 5 are actually numbers, otherwise prompt the user to re-enter them

Hope that help.
--

Christian Witts
Python Developer
//
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to