A trail log contains one marker per line. Iterating over an open file lets you process lines individually. This log uses blank lines for spacing and lines beginning with a hash for notes.
Clean a few ticket labels before choosing which ones to keep.
labels = [" A7\n", " \n", " --closed\n"]
kept = []
for raw in labels:
label = raw.strip()
if label and not label.startswith("--"):
kept.append(label)
print(kept) # ['A7']Checking the cleaned label handles an indented comment. In the trail log you will also count repeated labels.
Implement count_markers(path). Strip whitespace from each line. Skip empty lines and lines whose first remaining character is #. Return a dictionary that counts each distinct marker. Keep marker names case-sensitive.
# Example file contents: "East\n # map note\nEast\nWest\n"
# count_markers(path) returns {"East": 2, "West": 1}