I’m learning Python and i’m having some troubles on this script:
Preformatted text
#open- read and split a text file
with open (“login_attempts.txt”, “r”) as file:
file_text = file.read()
print(file_text.split())
usernames = file_text.split()
#create a function that counts a user failed login attempt
def login_check(login_list, current_user):
counter = 0
for i in login_list:
if i == current_user:
counter = counter + 1
if counter <= 2:
return “You have tried to login three or more times. Your account has been locked”
else:
return “You can log in”
login_check(usernames, “eran”)Preformatted text
The problem is that I see the list of usernames as requested but i don’t get any message regarding being allowed to login or not.
Thank you for your time.