If I have a string "2+3", is there anyway to convert it to an integer so it comes out as 5?
I tried this:
string = 2+3
answer = int(string)
But I get an error:
ValueError: invalid literal for int() with base 10: '2+3'
I'm trying to take a fully parenthesized equation and use stacks to answer it.
ex. Equation = ((2+3) - (4*1))
I tried taking the equation as an input, but python just solves it on its own. So to avoid that problem, I took the equation as a raw_input.
evalis actually a function that does exactly this!