Reputation: 35
In python, if I have a list
lst=["Word", "Bar", "List", "Warrior", "When", "Apple", "Car"]
and I want to determine for each element if the next element is a word that begins with W
, how could I write my for loop?
Upvotes: 0
Views: 38
Reputation: 711
lst=["Word", "Bar", "List", "Warrior", "When", "Apple", "Car"]
for i in range(len(lst) -1):
if lst[i + 1][0] == "W":
print(i)
Upvotes: 1