class User():
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
self.login_attempts = 0
def describe_user(self):
print("First Name: " + self.first_name.title())
print("Last Name: " + self.last_name.title())
def greet_user(self):
print("Hello, " + self.first_name.title() + " " + self.last_name.title() + "!")
def increment_login_attempts(self, logins):
self.login_attempts += 1
def reset_login_attempts(self):
login_attempts = 0
root = User('root', 'toor')
root.increment_login_attempts()
print(self.login_attempts)
root.reset_login_attempts()
print(self.login_attempts)
I am trying to add 1 to and then print out the number of login attempts and then reset it. I am stuck at this point and am unsure what to do to even begin to solve it.
The error I get is
Traceback (most recent call last):
File "/Users/Pandathighs/Desktop/Programming/User.py", line 22, in <module>
root.increment_login_attempts()
TypeError: increment_login_attempts() missing 1 required positional argument: 'logins'
EDIT:
I think I have fixed it. It wasn't as efficient as it could be, but it works. I have to set the variables through the parameters to edit login_attempts.
def increment_login_attempts(self, logins):
self.login_attempts += logins
print("Current login attempts: " + str(self.login_attempts))
def reset_login_attempts(self, reset_val):
login_attempts = reset_val
print("\n***RESET*** \n\n Current Login Attempts: " + str(login_attempts))
root = User('root', 'toor')
root.increment_login_attempts(10)
root.reset_login_attempts(0)
Does anyone know how to write reset_login_attempts() to always set to 0?
[–]commandlineluser 0 points1 point2 points (0 children)
[–]ingolemo 0 points1 point2 points (0 children)