May-12-2019, 07:15 PM
(This post was last modified: May-12-2019, 07:17 PM by michalmonday.)
It takes string as input and strings are easy to modify/organise. You can do this:
eval(str(s.pop()) + symbol + str(s.pop()))and it automatically replaces this part that you posted:
if symbol == "+": plus = s.pop() + s.pop() elif symbol == "-": plus = s.pop() - s.pop() elif symbol == "*": plus = s.pop() * s.pop() elif symbol == "/": plus = s.pop() / s.pop()You can also have a list of symbols and format them all into 1 eval function.