什么也没输入

时间:2017-10-18 20:46:56

标签: python

在继续之前,我需要添加什么来强制用户输入内容。

print()
print("Question 2")
print("What is the currency of Spain?")
print()
print("A  Euro")
print("B  Dollar")
print("C  Yen")
print("D  Krona")
answer = input("What is your choice: ").upper()

while answer is none #keep asking
if answer == "A":
       print("Correct!")
       score = score + 1
else:
       print("Sorry, the correct answer was A")

1 个答案:

答案 0 :(得分:-1)

在循环中再次提示输入:

print()
print("Question 2")
print("What is the currency of Spain?")
print()
print("A  Euro")
print("B  Dollar")
print("C  Yen")
print("D  Krona")

answer = input("What is your choice: ").upper()

while answer == "":
    answer = input("What is your choice: ").upper()
if answer == "A":
       print("Correct!")
       score = score + 1
       correct = True
else:
       print("Sorry, the correct answer was A")