File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 3
3
https://en.wikipedia.org/wiki/Polish_notation
4
4
"""
5
5
6
- calc = {
6
+ operators = {
7
7
"+" : lambda x , y : x + y ,
8
8
"-" : lambda x , y : x - y ,
9
9
"*" : lambda x , y : x * y ,
@@ -42,11 +42,11 @@ def evaluate(expression):
42
42
stack .append (int (c ))
43
43
44
44
else :
45
- # pop values from stack can calculate the result
45
+ # pop values from stack can operatorsulate the result
46
46
# push the result onto the stack again
47
47
o1 = stack .pop ()
48
48
o2 = stack .pop ()
49
- stack .append (calc [c ](o1 , o2 ))
49
+ stack .append (operators [c ](o1 , o2 ))
50
50
51
51
return stack .pop ()
52
52
@@ -65,10 +65,10 @@ def evaluate_recursive(expression: list):
65
65
"""
66
66
67
67
op = expression .pop (0 )
68
- if op not in calc :
68
+ if op not in operators :
69
69
return float (op )
70
70
71
- operation = calc [op ]
71
+ operation = operators [op ]
72
72
73
73
a = evaluate_recursive (expression )
74
74
b = evaluate_recursive (expression )
You can’t perform that action at this time.
0 commit comments