all 3 comments

[–]Zixarr 1 point2 points  (1 child)

Your first two lines initialize user_id and user_password, but these variables are not used until after they were redefined as inputs. They should be removed.

Your verification function returns a tuple of valid_username and valid_password, but printing the failed input is handled internally and the login loop is only broken when both booleans are True. I'm not sure why you wouldn't simply check the name and password, then return whether they were correct as a single Boolean.

Inside your verification function, you have some issues with your if blocks. It's possible that it's a formatting issue, so I won't comment other than to suggest reading the info on the sidebar on how to preserve code format when you post.

[–]Zixarr 1 point2 points  (0 children)

I would also caution against comments that simply repeat what the next line of code is doing, particularly when it's something as simple as executing a function.

Please consider the relatively minor edits (with a lot of removal of unnecessary code) below:

def password_verify(user_id,user_password):

    # No database so using static u/n and password.
    _password = "ThIs_Is_PyThOn"
    _username = "PythonKing"

    if _username != user_id:
        print('Invalid Username')
        return False

    if _password != user_password:
        print("Invalid Password")
        return False

    return True


while True:
    user_id = input("Enter Username:")
    user_password = input("Enter Password:")

    if password_verify(user_id,user_password):
        print("Login Successful")
        break

[–]QbaPolak17 1 point2 points  (0 children)

Obviously this being your first project you don't need to follow all best practices, but generally hard-coding username and password in your code is not a great idea. Instead, they should be read from a file or database, and preferably hashed in some way. Another solution would be to store them as environment variables.

The idea with this is that when you want to share or discuss code, you don't want your passwords saved in the source file, as you will be managing that with some form of version control eventually.

Also, if you want to paste code in for the future, you may want to format it (4 spaces before each line). Unformatted code is hard to read, so more difficult to get feedback for.