Closed. This question needs
CodePudding user response:
The problem seems to be you forgot parentheses after creating enemy1
.
class Enemy:
life = 3
def attack(self):
print('ouch')
self.life -= 1
def checklife(self):
if self.life <= 0:
print('i am dead')
else:
print(str(self.life) ' life left')
enemy1 = Enemy()
enemy1.attack()
enemy1.checklife()
And remember, it is much better to post the code as text rather than a picture.