iconic_creator — 2010-10-11T09:51:29-04:00 — #1
Good day everyone! Hope all is well.
I am trying to create an empty list, eg: week_days. then set up a loop for the user to enter each of the days of the week one at a time by using the append method, (Sunday, Monday, Tuesday, etc……………) and add the days to the list week_days as they are entered by the user.
This is what I have, not sure it's the right way.
weekdays = 
days = raw_input("Enter week days: ")
for days in weekdays:
Thanks everyone reading this.
felgall — 2010-10-11T16:43:14-04:00 — #2
You are only reading in one day and saving that to the list before looping through the list to output it.
You need to build the raw_input and append statements into a second loop where you keep requesting days and appending them to the list until some specific termination condifion is met (eg. not entering anything).
yahn — 2010-10-11T20:12:26-04:00 — #3
Additionally, you could comma separate the dates and use the split function built into Python.
If you're just trying to learn the language and how for looping works, sick with Felgall's recommendation.
Also, http://docs.python.org/tutorial/ is really all you need to learn the language.
7stud — 2010-10-12T03:16:18-04:00 — #4
As fegall said, you created a loop to output the results, but you didn't create a loop to gather the results. Here is an example of what you can do:
entered_data = 
while (1): #create an infinite loop
entered = raw_input("Type stuff ('q' to quit): ")
if entered in ['Q', 'q', 'Quit', 'quit']:
break #break out of the loop
for entered in entered_data: