AttributeError: объект «Пользователь» не имеет атрибута «show_privileges».Python

Программы на Python
Anonymous
AttributeError: объект «Пользователь» не имеет атрибута «show_privileges».

Сообщение Anonymous »

Python не распознает мою функцию def show_privileges

Код: Выделить всё

def __init__(self, first_name, last_name, login_attempts, email, location):
self.first_name = first_name
self.last_name = last_name
self.login_attempts = login_attempts
self.email = email
self.location = location

def describe_user(self):
print(f"{self.first_name} {self.last_name}")
print(f"You have {self.login_attempts} login attempts")
print(f"{self.email}")
print(f"{self.location}")

def greet_user(self):
print(f"Hi {self.first_name} {self.last_name} ")

def location_user(self):
print(f"Hi {self.first_name},you are from London, South")

def increment_login_attempts(self, login):
self.login_attempts = + login
Администратор класса (Пользователь):

Код: Выделить всё

    def __init__(self, first_name, last_name, login_attempts, email, location):
super().__init__(first_name, last_name, login_attempts, email, location)
self.privileges = []

def show_privileges(self):
print("\nPrivileges:")
for priviledge in self.privileges:
print(f"- {priviledge}")

admin = User("Fred", "Osei", "6", "fred@fredas.com", "London")
fred = User("John", "Chris", "8", "johnchris@life.com", "Manchester")
admin.describe_user()

admin.privileges = ["Can Post", "Can Create Accounts", "Can Delete Account"]
admin.show_privileges()
Я не понимаю, почему он не распознает функции show_privileges. Я считаю, что сделал все правильно

Подробнее здесь: https://stackoverflow.com/questions/788 ... privileges

Вернуться в «Python»