code:
def rpn():
list = []
while 1:
x = raw_input(" ")
if x in ["+","-","*","/","%"]:
y=str(eval(list[-2]+x+list[-1]))
list[-2:]=[y]
elif x == "":
break
elif x == "=":
print y
else:
list.append(x)
How can i modify my rpn calculator in order to:
1)accept random number
x = random number
e.g
x x x x x x
2)accept a stack variable
and pop each time a number:
e.g
1
2
3
+
stack
+
stack
=
3)accept comments
e.g
#comment
1 #comment
2 #comment
+
=
4) accept as input :
2
+
=
5) accept exponential
e.g
1 1 ^ 1 =
Please help me! Thank you!