Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python creating username and password program [closed]

Tags:

python

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.

like image 812
Polly the Programmer Avatar asked Sep 26 '26 00:09

Polly the Programmer


1 Answers

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.")
like image 162
Ajax1234 Avatar answered Sep 27 '26 15:09

Ajax1234



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!