我的Python代码中的语法错误无效[关闭]

问题描述 投票:-6回答:2

我一直在room105周围收到“无效语法”通知

*room15 = room("Check out the lab")

room15.setDescription("You look around the lab. You find nothing of importance, really."

room105 = room("Continue to look around")

room105.setDescription("You still don't find anything.")

room16 = room("Go back up trapdoor and into the sweet room")

room16.setDescription("You go up the ladder and into the room, only to find... The leader! He becomes startled, and begins to come at you!")


room106 = room("Talk to him")

room106.setDescription("you attempt to speak with the leader, but he comes at you too fast, and kills you.                                                                              GAME OVER.")

room106.setFunction(lambda: lockroom (room16))*

我正在尝试进行文字冒险。当我之前测试它时,它运行得很好,现在,只要我放入room105位,我就会收到一堆错误。

python syntax python-2.7
2个回答
6
投票
*room15 = room("Check out the lab")

room15.setDescription("You look around the lab. You find nothing of importance, really."

room105 = room("Continue to look around")

您缺少第二行的右括号。


1
投票

你的变量名称在开头和最后都有一个星号,这是非法的,但可能只是一个错字(但请在发布之前校对你的问题!)

你的实际问题是你在room15.setDescription(...之后错过了右括号

© www.soinside.com 2019 - 2024. All rights reserved.