Tell us what’s happening:
can i get help with this issue here?
test no.31 is failing where in the health setter in the line 23 has a similar test but when i try the same code in the line 36 for mana i get an error for some reason.
i would like a brief explaination on why this happened.
Your code so far
class GameCharacter:
def __init__(self,name):
self._name = name
self._health = 100
self._mana = 50
self._level = 1
@property
def name(self):
return self._name
@property
def health(self):
return self._health
@health.setter
def health(self,new_health):
if new_health < 0:
self._health = 0
elif new_health > 100:
self._health = 100
elif 0 < new_health < 100:
self._health = new_health
@property
def mana(self):
return self._mana
@mana.setter
def mana(self,new_mana):
if new_mana < 0:
self._mana = 0
elif new_mana > 50:
self._mana = 50
elif 0 < new_mana < 50:
self._mana = new_mana
@property
def level(self):
return self._level
def level_up(self):
self._level +=1
self.health = 100
self.mana = 50
print(f"{self._name} leveled up to {self._level}!")
def __str__(self):
return f"Name: {self._name}\nLevel: {self._level}\nHealth: {self._health}\nMana: {self._mana}"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Build a Game Character Stats Tracker - Build a Game Character Stats Tracker