-3
私は学校の仕事に戻って設定されているプログラムを完了しようとしていますが、私はPythonを使用したことがありません。嘘。これは作業が期限切れであるので、木曜日までにはどんな助けもありがとう!Python NameError:グローバル名 'score'が定義されていません
#revision platform
def Spelling():
global test
global score
score = 0
print("Welcome to the Spelling test.")
Q1=raw_input("Which spelling is correct:\nChangeable\nChangeble\n")
if Q1=="Changeable":
print("Correct")
score += 1
else:
print("Incorrect")
Q2=raw_input("Which spelling is correct:\nThreshhold\nThreshold\n")
if Q2=="Threshold":
print("Correct")
score += 1
else:
print("Incorrect")
Q3=raw_input("Which spelling is correct:\nScent\nSent\nCent\n")
if Q3=="Scent" or Q3=="Sent" or Q3=="Cent":
print("Trick Question they were all right!")
score += 1
print("Your score is:" ,score)
else:
print("Incorrect")
print("Your score is:",score)
ありがとうございました!
に動作しますスペル()関数を呼び出します。 –
どのようなエラーが表示されますか?あなたはその問題がより具体的になりますか?トレースバックを追加すると便利です –
問題は字下げです。しかし、なぜあなたはそれらの変数をグローバルとして宣言していますか? –