Python へのアプローチをより実践的にするために、この一連の youtube ビデオをフォローしてきました。一部のコードが何を行っているかについては深く理解していませんが、どのようにすればよいかはわからないかもしれませんが、それぞれの部分が達成するはずのことは多かれ少なかれ理解しています。
ここの最後の行で構文エラーが発生します。
class Character(object):
def __init__(self, name, hp):
self.name = name
self.hp = hp
self.dead = False
def attack(self, other):
pass
def update(self):
if self.hp < 0 #Error's on this line
self.dead = True
self.hp = 0
トレースバックは次のとおりです。
Traceback (most recent call last): File "game.py", line 4, in
<module>
from Characters.player import * File "/Users/Devlin/Desktop/Dev/Python/rpg/Characters/player.py", line 2,
in <module>
from character import * File "/Users/Devlin/Desktop/Dev/Python/rpg/Characters/character.py", line
12
if self.hp < 0
^ SyntaxError: invalid syntax