Issue
I know that I can set up an integer before the loop and increment it together with the loop. But is there another way?
Solution
Just enumerate()
the iterable:
for index, obj in enumerate(objects):
print index
(The name object
is a built-in type. To avoid shadowing this name, I renamed the loop variable to obj
.)
Answered By - Sven Marnach
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.