私は、あなたが気にしているファーム動物をコンピュータが知っているゲームを構築しています。彼はあなたの家畜を推測するためにあなたに質問します。しかし、私はエラーが発生し、私はそれを修正する方法を知らない。"elif"構文エラー
マイコード:
qs_one = raw_input("Do your animal walk on two legs? answar 'yes' or 'no'")
if qs_one == "yes":
qs_two = raw_input("Do your animal have a white skin? answar 'yes' or 'no'")
if qs_two == "yes":
print "Your animal is a goose!"
elif qs_two == "no":
print "Your animal is a chicken!"
else:
print "Error, try again."
elif qs_one == "no":
qs_two = raw_input("Do your animal have horns? answar 'yes' or 'no'")
if qs_two == "yes":
qs_tree = raw_input("Do your animal have stains? answar 'yes' or 'no'")
if qs_tree == "yes":
print "Your animal is a cow!"
elif qs_tree == "no":
qs_four = raw_input("Do your animal have goatee? answar 'yes' or 'no'")
if qs_four == "yes":
print "Your animal is a goat!"
elif qs_four == "no":
print "Your animal is a bull!"
else:
print "Error, try again."
else:
print "Error, try again."
elif qs_two == "no":
qs_tree = raw_input("Do your animal have a pink skin? answar 'yes' or 'no'")
if qs_tree == "yes":
print "Your animal is a pig!"
elif: # <- ERROR HERE
qs_four = raw_input("Can you ride your animal? answar 'yes' or 'no'")
if qs_four == "yes":
print "Your animal is a horse!"
elif qs_four == "no":
qs_five = raw_input("Does your animal have big ears? answar 'yes' or 'no'")
if qs_five == "yes":
"Your animal is a rabbit!"
elif qs_five == "no":
"Your animal is a sheep!"
else:
print "Error, try again."
else:
print "Error, try again."
else:
print "Error, try again."
else:
print "Error, try again."
else:
print "Error, try again."
がエラー:
Traceback (most recent call last):
File "python", line 30
elif:
^
SyntaxError: invalid syntax``
あなたのインデントはすべての場所にあります。問題を再現できるように、あなたの質問に*正しい*字下げがあることを確認してください。 –
あなたが探しているコマンドは、elifが条件を必要とするelse ifステートメントであるため、それ以外のものだと思います。 – thesonyman101