I am a beginner programing with Python 2.79. I am writing a program that \"tokenizes\" a mathematical formula, basically turning each number and operator into an item in a list
The reason Python is interpreting the user's input as an integer is because of the line input('Enter a math equation: ')
. Python interprets that as eval(raw_input(prompt))
. The raw_input
function creates a string from the user input, and eval
evaluates that input -- so an input of 5+2
is considered "5+2"
by raw_input
, and eval
evaluates that to be 7
.
Documentation