Unable to retrieve the planned messages

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()
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”
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.

In order to preserve formatting, please select any code or traceback that you post and then click the </> button.

The function login_check is returning the message, but you’re not doing anything with the result where it’s called. Python won’t print the result of a function automatically.

Thank you for your answer, so actually what I need to have one of those messages printed?

Use the print function.

1 Like

Thanks you, solved :slight_smile: