菜单以粗体显示其语法错误,我不知道如何解决

时间:2018-11-09 12:16:23

标签: python python-3.x

Menu()函数一直说它是语法错误,我不知道如何解决。

global celebritydoggame
def Menu():
        print ("Play,Quit Or Cards")
        choise = input(">?")
        if input == "Play" or "play":
            Deck()
        elif input == "Quit" or "quit":
            print("Thank You")
            quit()
        elif input == "Cards" or "cards":
                cards()

def cards():
        myfile = ("dogs.txt","r")


def Deck():
        print("How many cards do you want to play with in the game?")
        print("The amount of cards must be between 4-30, also you must choose a even number.")
        num = input(">?")
        if input == int >30:
           print ("error")
        elif input == int (4) <30:
            print ("ok the number of cards in play are"("int"))  
        elif input == int(num(4> int(num(30<
             print("Total of Cards must be over 4, under 30 and a even number"))

Menu()   

2 个答案:

答案 0 :(得分:1)

Deck函数的结尾处有一个多余的括号。

此外,您的条件似乎不对:例如重写

if input == "Play" or "play": 

if input == "Play" or input == "play"

UPD:您实际上在Dock函数中有很多错误,几乎每个printif都是错误的。我强烈建议您学习python语法。

答案 1 :(得分:1)

由于Deck()函数的最后两行而发生了。

elif input == int(num(4> int(num(30<
         print("Total of Cards must be over 4, under 30 and a even number"))

在这里,您没有正确关闭括号。

if函数中的Deck()语句也有问题。

if input == int >30:

input是一个从用户那里获取价值的功能。

几乎每个ifelif语句中都有一个错误。

即使在Menu()函数中,它也应该是这样的:

if input == "Play" or input == "play":
        Deck()