如何摆脱Elif语法错误

时间:2019-07-03 04:52:13

标签: python python-3.x

Image of Code Error

while Time5 == "true":
        Act5 = input("\nWhat would you like to do this year? You can: Play Videogames | Punch your parents | Browse the internet | Youtube | Steal Food |Check Stats | Check Assests: \n")
        if Act5 == "Check Stats":
            print("Your Stats")
            print("Sanity:{}".format(Sanity))
            print("Happiness:{}".format(Happiness))
            print("Health{}".format(Health))  
            print("Money{}".format((Money))       
        elif Act5 == "Steal Food": 
            print("You went over to your local Wendys and stole a Happy Meal.")
            Happiness = Happiness + 12
            print("The addreniline RUSH gave you 12 extra happiness\n")
            if Happiness > 100:
                print("Your HAPPINESS is maxed.")
            Wendy = input("You see another door to your left. It is the staff door. Will you enter? Yes or No \n")

我正在尝试制作生活模拟器。 在此部分,我一直收到无效的语法警告。 似乎没有缩进错误。 它曾经工作。 只有这部分无效 如果您想查看更多代码,请访问以下网站:https://docs.google.com/document/d/1HR5ahjM4B6wKOSEpeVRxXGrF9wCNTAp-OizdRl2zKuA/edit?usp=sharing并向下滚动到版本4。

1 个答案:

答案 0 :(得分:1)

我相信那条线

print("Money{}".format((Money))

给您带来麻烦,因为就像上面评论中的gilch所说,您的括号太多了。将该行修改为

print("Money{}".format(Money))

看看是否可行!