Skip to content
Snippets Groups Projects
Commit 9ae23a82 authored by ricchen's avatar ricchen
Browse files

fix too many args

parent 78233c96
No related branches found
No related tags found
No related merge requests found
......@@ -13,12 +13,18 @@ def calculate(arg):
elif token == '-':
result = val2 - val1
stack.append(result)
if len(stack) > 1:
raise ValueError('Too many arguments on the stack')
return stack[0]
def main():
while True:
result = calculate(input("rpm calc> "))
print(result)
try:
result = calculate(input("rpm calc> "))
print(result)
except ValueError:
pass
if __name__ == '__main__':
main()
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