I have a list and am iteratively performing a function on each item. I am trying to print out how far through the iteration the script is. The problem is that I can't easily get the position.
Here is what I have so far, but it generates a ValueError: 'item' is not in list
.:
that_number = len(mylist)
for i in mylist:
this_number = mylist.index(i)
print this_number, " out of ", that_number
DO SOMETHING
print "Done!"
I am aiming for the output:
1 out of 3
2 out of 3
3 out of 3
Done!
This question is related in that it is trying to find the position in a list, however is there a valid way of getting the element position without using enumerate
?