+ 2

I am getting a name error in a simple calculator program.

to run the code you enter 2 number and the first letter of one of 4 operations. a=+, s=-,m =*,d=/ https://code.sololearn.com/cbLVF8kdRQ50/?ref=app

31st Jul 2017, 5:54 AM
James Barrow
James Barrow - avatar
2 Answers
+ 7
The NameError is because a, s, m, and d are interpreted as variables, instead of values. To make them string values, surround them in either single quotes or double quotes. Then you can compare them to the input. Ex: if op == "a":
31st Jul 2017, 6:03 AM
Tamra
Tamra - avatar
+ 2
thanks that makes sence
31st Jul 2017, 6:05 AM
James Barrow
James Barrow - avatar