Python creating username and password program
53,162
Solution 1
You need to assign the second input statement to userInput:
if userInput == username:
userInput = input("Password?\n")
if userInput == password:
print("Welcome!")
else:
print("That is the wrong password.")
else:
print("That is the wrong username.")
Solution 2
You forget asign the variable:
if userInput == username
userinput = input("Password?\n")
if userInput == password:
print("Welcome!")
else:
print("That is the wrong password.")
else:
print("That is the wrong username.")
Related videos on Youtube
Author by
Polly the Programmer
Updated on July 17, 2022Comments
-
Polly the Programmer almost 2 years
I am just a beginner programmer as of right now, and I am trying to create a username/password program. Here is my code below:
username = 'Polly1220' password = 'Bob' userInput = input("What is your username?\n") if userInput == username: a=input("Password?\n") if a == password: print("Welcome!") else: print("That is the wrong password.") else: print("That is the wrong username.")
Whenever I run my program and input the correct password as shown, it always says that the password is incorrect.
-
Eugene Sh. almost 7 yearsYou never assign the password input to anything
-
-
Ajax1234 almost 7 yearsI did. Fixed now.
-
Polly the Programmer almost 7 yearsThank you so much!
-
Ajax1234 almost 7 yearsGlad I could help. Please consider accepting this response as answered so other users know it has an answer. Thank you.
-
Damian Lattenero almost 7 yearsYou were really fast on this one! plus one for that pal :)