So I am trying to count the number of times a certain character occurs from a score (.txt) file. The file says something like [$$$$$#$$#$$$]
Im trying to create a counter that counts the number of times $ occurs but resets every time a # happens.
This is all I have come up with so far but doesn't account for the restart.
with open ("{}".format(score), 'r') as f:
scoreLines = f.read().splitlines()
y = str(scoreLines)
$_count = int(y.count('$'))
The count is reflected in another part of the program which is outputting a wave. So every time a # occurs the wave needs to stop and start again. Any help would be appreciated!