[Tutor] working with empty lists
Joel Goldstick
joel.goldstick at gmail.com
Thu Sep 16 16:24:03 CEST 2010
I typed in this:
3 l = []
4
5 for i in range(0,10):
6 l.append(i+1)
7
8 for i in range(0,10):
9 print ('%s. %s' % (i, l[i]))
10
11 def paginate_stuff(list, start):
12 pagesize = 2
13 for i in list[start:start+pagesize]:
14 print ('%s. %s' % (i,list[i]))
15 return
16
17 paginate_stuff(l,0)
and i get this:
0. 1
1. 2
2. 3
3. 4
4. 5
5. 6
6. 7
7. 8
8. 9
9. 10
1. 2
2. 3
What are you expecting?
But I keep losing list[0]
>
> Im reasonably sure that it has something to do with my for loop, but I
> don't understand how
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
--
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100916/4505e2cb/attachment.html>
More information about the Tutor
mailing list