W dniu 2014-01-18 19:20, Pierre Dagenais pisze:
I wish to fill a list called years[] with a hundred lists called
year1900[], year1901[], year1902[], ..., year1999[]. That is too much
typing of course. Any way of doing this in a loop? I've tried stuff like
("year" + str(1900)) = [0,0] but nothing works.
Any solution?
Hi,
I don't know the solution, or if there is one.
And because of that, if I were you I would try to contain this data in
different way. Why not dictionary?
years = {1900: [0,0], 1901: [0,0], ..., 1999: [0,0]}
Initiating this dictionary with empty (or [0,0]) one hundred lists would
be easy with for loop. Accessing/changing list representing particular
year is much more easier: years[1980].
--
Best regards, Wiktor Matuszewski | Python
'py{}@wu{}em.pl'.format('wkm', 'ka') | newbie
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor