Skip to content
Snippets Groups Projects
Commit e31fc16f authored by ehcole's avatar ehcole
Browse files

implemented subtraction

parent 3b4cda10
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -9,7 +9,10 @@ def calculate(arg): ...@@ -9,7 +9,10 @@ def calculate(arg):
except ValueError: except ValueError:
val1 = stack.pop() val1 = stack.pop()
val2 = stack.pop() val2 = stack.pop()
result = val1 + val2 if token == '+':
result = val1 + val2
elif token == '-':
result = val2 - val1
stack.append(result) stack.append(result)
return stack[0] return stack[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment