I'm writing a small program to take a simple mathematical expression as input and evaluate it (haven't gotten that far as of yet).
The expressions only consist of +, -, /, and *. The problem I seem to be having is that whenever I input a string such as "1 + 2 + 3 + 4", I get an error:
1 2 3 4
invalid syntax
From what I can tell, the '+' is being interpreted as concatenation.
Is there a proper way to read a user input string that contains the + symbol?
Python 2.7
What I have:
expr = raw_input()
print expr
Given the input "1+2+3+4", python seems to automatically concatenate this to "1 2 3 4". I want the string to be verbatim, not concatenated