Fixes #8754, #8724 Updated postfix_evaluation.py

postfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes #8724. Added a doctest example with unary operator.
This commit is contained in:
Arijit De 2023-08-04 21:27:20 +05:30
parent d6874ad24f
commit b4521ea28f

View File

@ -88,6 +88,8 @@ def evaluate(post_fix: list[str], verbose: bool = False) -> int | float | str |
6.6 6.6
>>> evaluate(["2", "-", "3", "+"]) >>> evaluate(["2", "-", "3", "+"])
1 1
>>> evaluate(["-4", "5", "*", "6", "-"])
-26
>>> evaluate([]) >>> evaluate([])
0 0