Warum erkennt es nicht, dass ich mich selbst definiert habe?Python

Python-Programme
Anonymous
 Warum erkennt es nicht, dass ich mich selbst definiert habe?

Post by Anonymous »

Ich habe self () hier definiert < /p>

Code: Select all

# Player Stats
def self():
self.inventory = {}
self.current_pickaxe = None
< /code>
Ich versuche "self.current_pickaxe" zu verwenden, um Minen sowie XP zu entsperren. < /p>

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
< /code>
Fehler hier: < /p>
AttributeError: 'function' object has no attribute 'current_pickaxe'
Ich habe versucht, das "self.current_pickaxe" zu ändern, und es hat auch nicht funktioniert.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post