在python 2.7中執行的以下代碼給出了NameError
。關於互聯網安全的測驗
回溯是
answer1 = input("make a decision").Upper()
File "<string>", line 1, in <module>
NameError: name 'C' is not defined
的完整源代碼。
print("This is a quiz on Internet safety!")
print("Question 1")
print("What is a firewall?")
print("A-A killer hot wall!")
print("B-A protection from virus'")
print("C-A protection from bad websites!")
answer1 = input("make a decision").Upper()
if answer1 == "C":
print("Good!")
score = score+1
else:
print("You failed....")
quit
print("Question 2")
print("What is a virus?")
print("A-A killer disease! RUN!")
print("B-A harmful bit of mumbo-jumbo on the computer")
print("C-A harmful programme which encrypts the computer as invalid")
answer2 = input("make a decision").Upper()
if answer2 == "B":
print("Well Done!")
score = score+1
else:
print("You failed....")
quit
如果不工作,那麼是的,代碼是錯誤的。 – JJJ
請更正您的縮進。然後告訴最新的腳趾問題和你的Python版本是什麼? – Kasramvd
比「似乎沒有工作」更具體。 – interjay