Very Simple Calculator Help
4 minutes ago, Creepz said:
Traceback (most recent call last):
File "C:/Users/Devin/test.py", line 15, in <module>
operator = input('What do you want to do: multiply, divide, add, subtract?\n')
File "<string>", line 1, in <module>
NameError: name 'divide' is not definedProcess finished with exit code 1
hmm, odd
It seems as if it is treating the input as a variable, the one thing I can think of is using raw_input instead of input. But that shouldn't be an issue if the other operators work.
I'm not sure why it only raises the error in divide so these suggestions are kinda hacky fixes.
You might try specifying str(input()) to set the input as a string.
You can try double parenthesis " instead of '
Perhaps set the divide option as the default else:
Try putting the last part(after you enter divide) into a function
I would think maybe an install or version issue but again, the others working rule that out.
@fizzlesticks has more of a handle on python than I do
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now