私は現在、Python にまったく慣れていません。
私は多肢選択式クイズに取り組んできましたが、改善するたびに、より多くの問題が発生するようです。これはクイズ自体からの抜粋です。問題は、このコードを実行するたびに while ループが繰り返され続け、次のセクション q2 に進まないことです。
def q1(name):
print
q1= int(raw_input(
"""Question #1
Which of the following animals is native to New Zealand?
1) Possum
2) Rat
3) Tuatara
4) Sheep
Please enter your answer (1, 2, 3, 4)"""))
while q1 not in ["1", "2", "3", "4"]:
q1 = int(raw_input("choose 1, 2, 3 or 4."))
if q1 == 1 :
print
print"That is an incorrect answer. The possum is a native species of Australia."
W_A()
elif q1 == 2 :
print
print"That is an incorrect answer. The rat arrived on ships, assumedly along with first human inhabitants of New Zealand."
W_A()
elif q1 == 3 :
print
print'Well done',name.title(),'. That is the correct answer. The tuatara is endemic to New Zealand, and due to its close relation to the dinosaurs that roamed millions of years ago, they are sometimes referred to as a "Living fossil".'
R_A()
elif q1 == 4 :
print
print 'That is an incorrect answer. Sheep arrived with immigrants from Europe in the 1800s for agricultural purposes. They were used to provide wool and meat for farmers.'
W_A()
なぜこれが起こっているのか、また簡単な修正方法を知りたいです。あなたの援助は大歓迎です!