Skip to content

Commit fe4fba6

Browse files
author
Dan Finn
committed
small tweaks
1 parent 9939931 commit fe4fba6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

rpn.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"x" : (lambda a, b: a * b)
1111
}
1212

13-
def rpn(expression):
14-
tokens = expression.split()
13+
def eval_rpn(expression):
14+
""" Calculate a Reverse Polish Notation sequence """
1515
stack = []
1616

17-
for token in tokens:
17+
for token in expression.split(' '):
1818
if token in operators:
1919
# pull off the last 2 entries on the stack
2020
num2 = stack.pop()
@@ -29,6 +29,4 @@ def rpn(expression):
2929

3030
return stack.pop()
3131

32-
#print(rpn(input_string))
33-
34-
print(rpn(input_string))
32+
print(eval_rpn(input_string))

0 commit comments

Comments
 (0)