Reputation: 31
I want the if statement to correctly compare what is in the list to what the input is in the enter_password variable.
user_password = []
password = input("Enter what you would like your password to be. \n ENTER: ")
user_password.append(password)
print(f"Password created! Your password is: {user_password}")
enter_password = input("Enter password: ")
if enter_password == user_password:
print("Welcome")
else:
print(f"{user_password} is wrong password")
Upvotes: 0
Views: 193
Reputation: 369
You're appending your user input to a list and you're comparing it with string.
If you're going to check a single password, don't append it to a list, set it to a string aswell. Or if you need to check a password inside a list you can do it like this.
user_password = []
password = input("Enter what you would like your password to be. \n ENTER: ")
user_password.append(password)
print(f"Password created! Your password is: {user_password}")
enter_password = input("Enter password: ")
if enter_password in user_password: # This is the part that i've changed.
print("Welcome")
else:
print(f"{user_password} is wrong password")
Upvotes: 2