Python &引用;以英语发言;语法错误

Python &引用;以英语发言;语法错误,python,syntax-error,Python,Syntax Error,我正在制作一个游戏,让电脑知道你心目中的农场动物。他问你问题来猜你的家畜。但我有个错误,我不知道如何修复它 我的代码: 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

我正在制作一个游戏,让电脑知道你心目中的农场动物。他问你问题来猜你的家畜。但我有个错误,我不知道如何修复它

我的代码:

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."

您需要对
elif
设置一个条件,即

elif condition_is_true:
    *do something*

我认为您要做的是使用
elif qs_tree=='no':
。如果回答“是”,这是一头猪,如果回答“否”,这是另一回事,其他答案都应该给出“错误,再试一次”的信息

你的压痕到处都是。请确保您的问题中有正确的缩进,以便我们能够重现您的问题。我认为您要查找的命令是else,因为elif是需要条件的else if语句。可能只需要一个
else:
,因为前面的是
if qs_tree==“yes”:
到一个
'yes'
'no'
问题。@martineau我想他想要一个yes/no/else问题,因为只有两个有效的答案是yes和no。其他的一切都必须被
else
抓住。