Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
- C:UsersLiamAppDataLocalProgramsPythonPython36-32python.exe C:/Users/Liam/PycharmProjects/YouTube/first.py
- Traceback (most recent call last):
- File "C:/Users/Liam/PycharmProjects/YouTube/first.py", line 16, in <module>
- enemy1.attack()
- TypeError: attack() missing 1 required positional argument: 'self'
- Process finished with exit code 1
- enemy1 = Enemy()
- enemy1.attack()
- enemy1.checkLife()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement