私はPython 2でテキストベースのRPGをプログラミングしていますが、15行目でこのエラーが発生しています。 "SyntaxError:無効な構文"。私は多くのことを試みましたが、何も動作していないようです。Python - 「無効な構文エラー」が表示されるのはなぜですか?
def explore(self):
if self.state != 'normal':
print "%s is too busy right now!" % self.name
self.enemy_attacks()
else:
if x > 0:
print "%s's eyes adjust to the light and %s explores a strange passage." % (self.name, self.name)
if randint(0, 1):
self.enemy = Enemy(self)
print "%s encounters %s!" % (self.name, self.enemy.name)
self.state = 'fight'
else:
if x > 1:
if x < 2:
print: "%s explores the strange passage in hopes of finding ways out" % self.name
印刷後にコロン(:)を取り除く – Nick
別名:このPython 3をタグ付けしましたが、Python 3では、印刷する引数の前後にかっこを使用する必要があり、%sの書式設定は多少ファッションから外れています。あなたのコードがあなたのPythonバージョンと一致するかどうかを再確認したいかもしれません。 – DSM