Paul Rubin wrote:
Esmail writes:
for i in range(0, len(li)):
print li[i]
Will this always be equivalent to
for i in li:
print i
Not the same--after the exit of the first loop, 'i' is the length of
the list. After the exit of the second loop, 'i' is the last element.
Yes, agree
Esmail writes:
> for i in range(0, len(li)):
> print li[i]
>
> Will this always be equivalent to
>
>
> for i in li:
> print i
Not the same--after the exit of the first loop, 'i' is the length of
the list. After the exit of the second loop, 'i' is the last element.
> Would the 2nd o
Thanks everyone, as usual, very informative posts!
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Esmail wrote:
Hello all,
I have a simple question regarding semantics.
Given a list 'li', I can always do this to iterate through all items in
order:
for i in range(0, len(li)):
print li[i]
Will this always be equivalent to
for i in li:
print i
I assume it is, and the order will al
On Tue, 21 Apr 2009 21:06:46 -0400, Esmail wrote:
> Given a list 'li', I can always do this to iterate through all items in
> order:
>
> for i in range(0, len(li)):
> print li[i]
>
> Will this always be equivalent to
>
> for i in li:
> print i
For lists, yes, that will always be equ
Esmail wrote:
Hello all,
I have a simple question regarding semantics.
Given a list 'li', I can always do this to iterate through all items in
order:
for i in range(0, len(li)):
print li[i]
Will this always be equivalent to
for i in li:
print i
I assume it is, and the order will al
Hello all,
I have a simple question regarding semantics.
Given a list 'li', I can always do this to iterate through all items in
order:
for i in range(0, len(li)):
print li[i]
Will this always be equivalent to
for i in li:
print i
I assume it is, and the order will always be the sam