Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python for loop counter

# The pythonic way to find the count in a for-in loop (by using 'enumerate')

#count=0
for idx, item in enumerate(list):
    print item
    #count +=1
    #if count % 10 == 0:
    if (idx+1) % 10 == 0:
        print 'did ten'
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #loop #counter
ADD COMMENT
Topic
Name
8+9 =