[Python] Why is it not recognizing that I defined self?

Discussão em 'Python' iniciado por Stack, Março 22, 2025.

  1. Stack

    Stack Membro Participativo

    I defined self() here

    # Player Stats
    def self():
    self.inventory = {}
    self.current_pickaxe = None


    I'm trying to use "self.current_pickaxe" to unlock mines as well as xp.


    def mine_resources(location):
    global xp
    # Check if the player has the required pickaxe
    required_pickaxe = pickaxe_requirements[location]
    if required_pickaxe and self.current_pickaxe != required_pickaxe:
    print(f"You need a {required_pickaxe} to mine here.")
    return


    Error Here:

    AttributeError: 'function' object has no attribute 'current_pickaxe'


    I tried to change the "self.current_pickaxe" and it didn't work either.

    Continue reading...

Compartilhe esta Página