text = "hello+there$" position = 0 def parseLetter(): # a | b | ... | y | z global text, position if text[position] < "a" or text[position] > "z": return False position += 1 return True def parseIdentifier(): # letter | letter identifier global text, position if not parseLetter(): return False parseIdentifier() return True print(parseIdentifier()) print(position)