Python loop with int iterator [duplicate]
I seem to开发者_JAVA百科 recall there is a built-in way of doing this:
i = 0
for value in values:
# ...Stuff
i += 1
but in a neater syntax; something like
for value, i in fn(values):
# ...Stuff
Is my memory correct; and if so, what is the way of doing this?
for i, value in enumerate(values):
精彩评论