Any help appreciated! Text based RPG

Question:
I’m a newbie to coding with python but I tried to give it a go and I’m having trouble with my stats menu for the player. It says I haven’t assigned an attribute and I’m just kinda stumped, any help at all will be great. thanks in advance!

Repl link:
https://replit.com/@GoodIdeas/Crimson-Intent?v=1

code snippet:

class Vampire:
    def __init__(self, name, age, clan):
        self.name = name
        self.age = age
        self.clan = clan  
        self.resources = {"blood": 10, "money": 100}
        self.location = "town square"
        self.health = 100
        self.is_daytime = False
        .........
def display_stats(self):
          print(f"Name: {self.name}")
        print(f"Age: {self.age}")
        print(f"Clan: {self.clan}")
        print(f"Resources: {self.resources}")
        print(f"Health: {self.health}")
        print(f"Daytime: {self.is_daytime}")
1 Like

That is not the problem here. They defined it correctly, however the markdown got rid of the four underscores.

2 Likes

oops… well… um… nvm…

Well the class vampire does not have a method called display_stats … hence the error.

3 Likes

oh my god, of course it is something so simple, thank you so much!

The proper Class would be:

class Vampire:
    def __init__(self, name, age, clan):
        self.name = name
        self.age = age
        self.clan = clan  
        self.resources = {"blood": 10, "money": 100}
        self.location = "town square"
        self.health = 100
        self.is_daytime = False
        .........
    def display_stats(self):
        print(f"Name: {self.name}")
        print(f"Age: {self.age}")
        print(f"Clan: {self.clan}")
        print(f"Resources: {self.resources}")
        print(f"Health: {self.health}")
        print(f"Daytime: {self.is_daytime}")
2 Likes

Please mark @whileTRUEpass’s post as the solution if it solved your problem.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.