I am trying to create a RPN calculator, the addition and subtraction functions work but it only accepts numbers under 10. How can I fix this so any integers are allowed? Thanks.
import sys
accepted = '0123456789dr+-*/%^='
numbers = '0123456789'
stack = []
while len(stack) <= 20:
while True:
mystr = raw_input("")
try:
if mystr in accepted:
for x in mystr:
if mystr in numbers:
for x in mystr:
mystr = int(mystr)
stack.append(mystr)
if mystr == "+":
temp = stack.pop()+stack.pop()
stack.append(temp)
if mystr == "-":
temp = stack.pop(-2)-stack.pop()
stack.append(temp)
if mystr == "=":
print stack[-1]
break
print "Unrecognised Input."
except:
sys.exit()