1
私は、さまざまな困難で動作するクイズを作っています。唯一のことは、私のコードのように、私のif文を一番下で無視するということです。 9つの質問に答えた変数 'w' = 9があっても、まだループしている文は印刷されません。私はちょうど私のifステートメントを動作させるためにちょっとした助けが必要です
import csv
w = 0
score = 0
global q
with open("Computing.txt", "r") as file:
reader = csv.reader(file)
for row in reader:
dif_c = str(dif) + " "
if dif_c + str(q) + ")" in row[0]:
print (row[0].split(dif_c)[1])
print (row[1])
if dif == 1:
print (row[2])
input10 = input("Answer 'a' or 'b': ")
elif dif == 2:
print(row[2] + "\n" + row[3])
input10 = input("Answer 'a','b' or 'c': ")
elif dif == 3:
print(row[2] + "\n" + row[3] + "\n" + row[4])
input10 = input("Answer 'a','b','c' or 'd': ")
if input10 == row[dif + 2]:
print("Correct")
score = score + 1
w = w + 1
elif input10 != row[dif + 2]:
print("Incorrect")
w = w + 1
if w == 9:
print("Game over")
print("You got", r, "right out of 10")
while True:
quiz()
これは、すべてのクイズの関数であり、私はワット定義されたと私は仕事wouldntの知っている関数内で0として得点が、私はどのようにそれを修正する