I am iterating over a list and I want to print out the index of the item if it meets a certain condition. How would I do this?
Example:
testlist = [1,2,3,5,3,1,2,1,6] for item in testlist: if item == 1: print position
No comments:
Post a Comment