Assume I have a list and I am looping in it with for-in syntax. Can this be done with for-in syntax or better question would be what is the most pythonic way to do this?
l= ["ok", "item1", "nope", "item2", "nope", "item3", "ok", "item4"]
for item in l:
if item == "ok":
print(item + ": " + ... ) # Where ... should be next item
I want this code prints out something like
ok: item1
ok: item4
edit: A more clear list example would be like accourding to comments:
l= ["ok", "item1", "nope", "item2", "somevalue","nope", "item3", "ok", "item4"]