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