This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from operator import add, sub, mul, truediv as div | |
| operations = {"+": add, "-": sub, "*": mul, "/": div} | |
| stack = [] | |
| def upn(line): | |
| for token in line.split(): | |
| if token in operations: | |
| b, a = stack.pop(), stack.pop() |
NewerOlder