Last active
December 27, 2015 10:59
-
-
Save firstspring1845/7314981 to your computer and use it in GitHub Desktop.
逆ポーランド電卓
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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