I am processing a text file with an irregular structure that consists of a header and of data in different sections. What I aim to do is walk through a list and jump to the next section once a certain character is encountered. I made a simple example below. What is the elegant way of dealing with this problem?
lines = ['a','b','c','$', 1, 2, 3]
for line in lines:
if line == '$':
print("FOUND END OF HEADER")
break
else:
print("Reading letters")
# Here, I start again, but I would like to continue with the actual
# state of the iterator, in order to only read the remaining elements.
for line in lines:
print("Reading numbers")
lines.index('$')
to get the separator position?