Python Class __init__ 语法错误

Python Class __init__ syntax error

from game_state import GameState
class TippyGameState(GameState):
    def __init__(self, p, interactive=False, current_total = 0):
        GameState.__init__(self, p)
        if interactive:
                self.size = int(input('Map size?')
                self.current_total = self.size * self.size
        self.size = 3
        self.over = (current_total < 1)

当我在终端中 运行 时,它总是显示从 self.current_total = self.size * self.size 到结尾的语法错误,有人能告诉我为什么吗?

替换

self.size = int(input('Map size?')

self.size = int(input('Map size?'))

在这种情况下,请尝试查看上一行。 将 self.size = int(input('Map size?') 替换为 self.size = int(input('Map size?'))