I'm a little bit new to python and I'm currently practicing classes, subclasses and the super() method. I've been creating a small RPG (or at least the base concept) in Python and I've created the base class and can't seem to pull the data in a subsclass.
Here's the relevant code:
class base_human:
def __init__(self, health, magic, speed):
self.health = health
self.magic = magic
self.speed = speed
## Is the base class
class Warrior(base_human):
def __init__(self, name):
self.name = name
super().__init__(self, health, magic, speed)
## Is my sub class
base_human = base_human(10, 10, 10)
Brian = Warrior("Brian")
print(Brian.health)
print(Brian.name)
## Is the final print to test.
I'm currently getting the following error:
Traceback (most recent call last):
File "/Users/zuikis/Desktop/PI Projects/Classes/RPG 2.py", line 48, in <module>
Brian = Warrior("Brian")
File "/Users/zuikis/Desktop/PI Projects/Classes/RPG 2.py", line 32, in __init__
super().__init__(self, health, magic, speed)
NameError: name 'health' is not defined
Grateful for any help and forgive me if I've made a mistake in the format of the post, any further advice would be well received. Thanks so much.