Assignment
University
University of ReginaCourse
Computer Science (UR)Pages
2
Academic year
2023
Avaiya Priyank
Views
0
Q3. Write a program that uses a dictionary that contains ten user names and passwords. The program should ask the user to enter their username and password. If the username is not in the dictionary, the program should indicate that the person is not a valid user of the system. If the username is in the dictionary, but the user does not enter the right password, the program should say that the password is invalid. If the password is correct, then the program should tell the user that they are now logged in to the system. disc={"harsh22":"1234","harsh1":"2345","hacker":"1452","hacker22":"8523","harsh18":"123","harsh82":"5236","smit22":"8569","smit18":"8947","smit":"6521","ppsu":"6543"} user=input("Enter the username: ") passw = input("Enter the password: ") for i,j in disc.items(): if user==i and passw==j: print("You have logged into system") break elif user!=i: print("the person is not a valid user of the system. ") break elif user==i and passw!=j: print("the password is invalid. ") break
User Authentication Program using Python Dictionary
Please or to post comments