Aug-13-2019, 09:11 PM
This is likely Python 101.
I have searched for a straight forward simple answer to no avail.
How can I increment a list item while inside a "for x in List" loop.
I want to process two list items in sequence based on the first item having a given value. Then move on through the loop structure.
I have searched for a straight forward simple answer to no avail.
How can I increment a list item while inside a "for x in List" loop.
I want to process two list items in sequence based on the first item having a given value. Then move on through the loop structure.
items = [ "Thing", "apple", "dog", "house", "Thing", "bugs", "ducks", "rabbits"] # Start my loop over the list for i in items: if i == "Thing": print(i) # increment(i)?? print(i) # this should print the next item in the list after the last "Thing" # output I want is: # Thing # apple # Thing # bugs