On 26/09/13 12:29, Rafael Knuth wrote:

At some stage it will cover reading and writing to files as well as data
structures that will help store your data more effectively and looping
constructs that will help you process it more effectively.
...
(insofar it's usable at all) ..? Weirdly, writing and reading to files
is not covered in those tutorials I am working with.

Really? Then I'd consider finding another tutorial file access is pretty fundamental to any non trivial program.

You could try mine(see below) or any of the many other tutorials available.


print("This is my to do list")

Monday = input("Monday ")
Tuesday = input("Tuesday ")
Wednesday = input("Wednesday ")
Thursday = input("Thursday ")
Friday = input("Friday ")
Saturday = input("Saturday ")
Sunday = input("Sunday ")

This has lots of problems. What happens if you have more
than one thing to do on any given day? What if you want
more than one week? Data collections such as lists and
dictionaries can cope with those situations much better.

days = {}
days['Monday'] = input('What to do on Monday?')

print days['Monday']

etc.

Using loops covers the multi-todo situation:


events = []
for current in ('Monday','Tuesday',...etc):
   while True:
      event = input('What to do?')
      if not event: break  # exit loop on empty input
      else: events.append(event)
   days[current] = events



Or you could pick a day from a menu...


print("So, here are your plans for:" +
"\nMonday " + Monday +
"\nTuesday " + Tuesday +
"\nWednesday " + Wednesday +
"\nThursday " + Thursday +
"\nFriday " + Friday +
"\nSaturday " + Saturday +
"\nSunday " + Sunday)

Again a loop will do this:

for day in days:
    print day
    for event in events:
        print '\t' + event

That would produce output like:

Monday
   go to doctor
   go to funeral parlour
Tuesday
   die
Wednesday
   get buried


HTH

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor



--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to