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
answer = int(input("What is the name of Dr. Bunsen Honeydew's assistant?"))
File "", line 1, in
NameError: name 'Beaker' is not defined
解决方案
You are using input instead of raw_input with python 2, which evaluates the input as python code.
answer = raw_input("What is the name of Dr. Bunsen Honeydew's assistant?")
if answer == "Beaker":
print("Correct!")
input() is equivalent to eval(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:
answer = "Beaker"
if answer == "Beaker":
print("Correct!")
And with input:
answer = Beaker # raises NameError, there's no variable named Beaker
if answer == "Beaker":
print("Correct!")