Here is a demo list. It is a list of strings:
list_one = ['3', '5', '6', 'Week 1', '11', '12', '13', 'Week 2', '279']
Here is my code:
counts = []
for num, i in enumerate(list_one):
if "Week" in i:
counts.append(num)
num = 0
print(counts)
Instead of the output [3, 7], I'd like to get [3, 3]
I don't want to count any element that has already been counted and to exclude countings weeks themselves. In my head, I'm imagining resetting the num back to 0 after every occurrence of 'Week' in order to accomplish this but it isn't working.