Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def read_format(f):
- line = input().split()
- tokens = []
- for i in range(len(f)):
- token, line = f[i](line, i == len(f)-1)
- tokens.append(token)
- return tokens
- def _parse_f(f):
- return lambda words, last: (f(words[0]), words[1:])
- getal = _parse_f(int)
- kommagetal = _parse_f(float)
- def tekst(words, last):
- if last: return " ".join(words), []
- return words[0], words[1:]
- i, = read_format([getal])
- print(i)
- j, s = read_format([kommagetal, tekst])
- print(j, s)
Add Comment
Please, Sign In to add comment