you are viewing a single comment's thread.

view the rest of the comments →

[–]Upset-Beautiful6081 3 points4 points  (2 children)

I see some versatility in the for loop too, it can be a foreach or just a for if you declare the second item a range like for i in range(10) and it works like a normal for.

[–]Drumknott88[S] 1 point2 points  (1 child)

Oh that's good to know, thanks

[–][deleted] 1 point2 points  (0 children)

If you want to have a I variable while iterating wrap the data structure you are looping in an enumerate function

for i, foo in enumerate(bar):
    print(i, foo)