Closed
Description
Feature description
As mentioned in #8724, we have two files for evaluating postfix expressions. But currently both of them only work with binary operators and will raise an exception when an unary operator is given.
example:
>>> res = evaluate_postfix(["2", "-", "3", "+"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../stacks/evaluate_postfix_notations.py", line 31, in evaluate_postfix
b, a = stack.pop(), stack.pop()
IndexError: pop from empty list
>>>
2-3+
is a postfix notation for -2+3
infix and should result in 1
.