I am programming a python game, and my Hero class starts like this:
class Hero():
def __init__(self, name):
self.class = ""
while self.class not in ["mage", "fighter"]:
print("What class are you?")
self.class = input("Mage or Fighter: ").lower()
self.name = name.title()
self.level = 1
self.enimieskilled = 0
self.hp = self.level * 5
self.attacks = spells[self.class]
I have later created a hero with player = Hero(input("What is your name? "))
But when I run this program, I get:
File "app.py", line 26
self.class = ""
^
SyntaxError: invalid syntax
I tried commenting out all the self.class's, as so:
class Hero():
def __init__(self, name):
#self.class = ""
#while self.class not in ["mage", "fighter"]:
# print("What class are you?")
# self.class = input("Mage or Fighter: ").lower()
self.name = name.title()
self.level = 1
self.enimieskilled = 0
self.hp = self.level * 5
#self.attacks = spells[self.class]
and it runs. I have checked and all of the parenthesis are ok.