Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

loop only to the 6th element python

sample = "This is a string"
n = 3 # I want to iterate over every third element
for i,x in enumerate(sample):
    if i % n == 0:
        print("do something with x "+x)
    else:
        print("do something else with x "+x)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #loop #element #python
ADD COMMENT
Topic
Name
7+9 =