Answer to Question #279795 in Visual Basic for Gwen

Question #279795

Write a python program using conditional statements design a login where a user will enter a username and password




A) on successful login a welcome message is displayed





B) on 3 attempts an invalid message is displayed informing the user of the attempts remaining





C)on the fourth unsuccessful attempt the program will exit and inform the user of failed attempts

1
Expert's answer
2021-12-15T07:00:20-0500
attempts = 0
while attempts < 4:
    username=input("Enter username: ")
    password=input("Enter password: ")
    if username == "admin" and password == "1111":
        print("You're Welcome")
        attempts = 5
    else:
        attempts += 1
        print("Wrong username or password.")
    if attempts == 3:
        print("Wrong username or password. 1 attempts remaining")
if attempts !=5:
    print("4 failed attempts")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS