So what am I doing wrong here?
answer = int(input("What is the name of Dr. Bunsen Honeydew's assistant?"))
if answer == ("Beaker"):
print("Correct!")
else:
print("Incorrect! It is Beaker.")
However, I only get
Traceback (most recent call last):
File "C:\Users\your pc\Desktop\JQuery\yay.py", line 2, in <module>
answer = int(input("What is the name of Dr. Bunsen Honeydew's assistant?"))
File "<string>", line 1, in <module>
NameError: name 'Beaker' is not defined
Why are you using
int
and expecting string on input.?useraw_input
for your case, it captures every possible values ofanswer
as string. so in your case it would be something like this:OR
if you are using only
input
. expect 'answer' or "answer" for string. like:similarly to use
int
ininput
, Use it like:But if you type:
You are using
input
instead ofraw_input
with python 2, which evaluates the input as python code.input()
is equivalent toeval(raw_input())
Also you are trying to convert "Beaker" to an integer, which doesn't make much sense.
You can substitute the input in your head like so, with
raw_input
:And with
input
: