+ 5
[Solved] Why it's giving AttributeError?
#Plz tell me ASAP class User: def __init__(self, first_name, last_name, age, login_attempts): self.first_name=first_name self.last_name=last_name self.age=age self.login_attempts=login_attempts def show_login_attempts(self): print(self.login_attempts) def increment_login_attempts(self): self.login_attempts+=1 return f"{self.first_name} {self.last_name}'s have been updated" def reset_login_attempts(self): self.login_attempts=0 return f"Login attempts have been reset to 0" user1=User("Keshav", "Kumar", 17, 5) user2=User("Eric", "Matthew", 42, 10) print(user1.login_attempts) user1.reset_login_attempts()
1 Answer
+ 1
because of the indentation. And it also wont print unless you either call: print(user1.reset_login_attempts())
OR
call print in the method
https://code.sololearn.com/c1WYT1V56R4A/?ref=app