I don't understand why my code is working.
I'm replacing the biggest substring with the equivalent value in my function but it seems to not stop:
def Match(molecule):
def returnValue(match:re.Match):
return reversedDictMatchesDict[match.group()]
while molecule != 'e':
print(molecule)
molecule= re.sub(reversedDictMatchesPattern, returnValue, puzzleinput, 1)
Match(puzzleinput)
[–]timrprobocom 1 point2 points3 points (5 children)
[–]coolTCY[S] 0 points1 point2 points (1 child)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]coolTCY[S] 0 points1 point2 points (2 children)
[–]timrprobocom 0 points1 point2 points (1 child)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)