I'm trying to make a python calculator that takes inputs like these:
>>> 2+2*3
or
>>> 3*45+2*52/3
or
>>> 1+21/7-14/2
And return their answers with order of operations in mind. I am not allowed to use any modules and I get user inputs in one line, one string. And basically there is no limit on how many operations user can enter.
I tried to strip away my operators and numbers like this:
userin=input()
operators=[]
numbers=userin.replace('+',' ').replace('-',' ').replace('*',' ').replace('/',' ').split()
for char in userin:
if char=='+' or char=='-' or char=='*' or char=='/':
operators.append(char)
But my brain has stopped after trying to do basic math with order of operations this weekend. Any help?