I'm messing around with Class' and I have a python3 file with the following code:
class playerstats(object):
def __init__(self, name, baselevel=1, hp, mana, basedmg=0, atkdmg, basedef=0, chardef):
self.name = name
self.baselevel = baselevel
self.hp = hp
self.mana = mana
self.basedmg = basedmg
self.atkdmg = atkdmg
self.basedef = basedef
self.chardef = chardef
return self.name, self.baselevel, self.basedmg, self.basedef
def selectedclass(self, chosenclass):
if chosenclass == 'W' or chosenclass == 'w':
self.hp = 100
self.mana = 50
elif chosenclass == 'M' or chosenclass == 'm':
self.hp = 75
self.mana = 100
else:
print('Error')
return self.hp, self.mana
charcreation = playerstats('Tom', baselevel, self.chosenclass, self.chosenclass, basedmg, 0, basedef, 0)
self.chosenclass = 'w'
print(playerstats.hp)
When I run it, I get this Error: File "..\Playground\", line 2 def init(self, name, baselevel=1, hp, mana, basedmg=0, atkdmg, basedef=0, chardef): ^ SyntaxError: non-default argument follows default argument
Can someone help me understand why?