Stacks and queues · stretch
Reverse Polish calculator
In reverse Polish notation the operator comes after its two numbers: 3 4 + is 7 and 5 1 2 + 4 * + 3 - is 14.
Write evaluate(tokens) for a list of strings — whole numbers and +, -, * — returning the number.
- right answers
- arguments left as they should be
- without eval
Run adds print(evaluate(["3", "4", "+"])) after your code, to try it.
Stuck on the idea rather than the code? The Stacks and queues lesson walks through it.