for statement on empty iterable

Eric Abrahamsen eric at abrahamsen.com
Wed Aug 22 03:45:05 EDT 2007


Here's another simple method:

l = ['j', 'a', 'm', 'e', 's']
counter = 0

for i in l:
     # Do your code
     counter += 1

print counter

Yrs,
Eric

> l = ['j', 'a', 'm', 'e', 's']
>
> for i in l
>  # i want to know the nth number of times it has loop thru or
> something like counter?
>
> Thanks
> james
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>




More information about the Python-list mailing list