Skip to content

Instantly share code, notes, and snippets.

@firstspring1845
Last active December 27, 2015 10:59
Show Gist options
  • Save firstspring1845/7314981 to your computer and use it in GitHub Desktop.
Save firstspring1845/7314981 to your computer and use it in GitHub Desktop.
逆ポーランド電卓
stack = []
for s in raw_input().split():
if s in ('+','-','*','/'):
stack.append(eval('{2}{1}{0}'.format(stack.pop(),s,stack.pop())))
else:
stack.append(int(s))
print stack.pop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment