I am getting this error
AttributeError: 'str' object has no attribute 'health'
I think it is because the object I am trying to modify is a attribute of the instance, but when I refer to the instance I get user input that changes it to a string. How can I change it so that the string refers to the instance instead? I have looked at a post here but it was from 5 years ago and it seems outdated and didn't help.
so in the terminal it shows
Heal who? Rachel # I entered the Rachel part
which is from this part of the code
heal = input("Heal who? ")
Sidekick.heal(heal)
and it executes
def heal(self,target):
"""Heals the target by 20 hp."""
if self.level <= 5:
restore = 20
elif self.level <= 10:
restore = 35
elif self.level <= 15:
restore = 50
target.health += restore
if target.health > target.full_health:
restore = target.full_health - target.health
target.health = target.full_health
print("Healed " + target.name + " by " + str(restore) + " hp.")