[Tutor] Naming variables
Danny Yoo
dyoo at hashcollision.org
Sun Jan 19 03:30:08 CET 2014
If we wanted to do something with something like:
year0 = 0
year1 = 0
year2 = 0
...
year999 = 0
where we keep a thousand years, and set them all to zero, then you're
right in thinking that having one thousand separate variables is
probably not a viable approach.
We can handle this uniformly, though, by using a list.
year = [0] * 1000
'year' is now a list with 1000 elements, all of which are zero. We
can access each in turn:
year[0]
year[1]
year[2]
....
year[999]
and see that they all have zero in them.
More information about the Tutor
mailing list