Write a program that uses a dictionary that contains ten usernames and passwords. The program should ask the user to enter their usernames and passwords. 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, the program should tell the user that they are now logged into the system. (PYTHON)
Answers
Answer:
wrote a program in python3.6 that the user creates a username and password. then the program checks if that username is stored if not it creates the username and password permanently.I am having trouble linking username and password lists as 'jason' has the password 'oero'.
so that the
if sentence == stored_username[0:] and sentence2 == stored_password[0:]:
print(Aceppted)
runs as 'jason' is the the username and oero is the password.
the other problem is when I ran the program it tried to run the entire list so you cant choose just one value of the lists. This is what I have so far. the program is also set to quit if the user gets their username and password wrong 3 times. which works fine. Thank you! The code runs as is, the way its supposed too.
username= input('Create Username')
password= input('Create Password')
stored_username =['jason' , 'nicole',username]
stored_password =['oeros', 'chance',password]
print(stored_username[0:])
trials =0
def sign_in():
global username
global password
global stored_username
global stored_password
sentence= input('Enter Username')
print(sentence)
sentence2 = input('Enter Password')
print(sentence2)
global trials
Aceppted= 'Welcome to Bacall Land'
wrong=('Wrong Username or Password ')
if sentence == stored_username[0:] and sentence2 == stored_password[0:]:
print(Aceppted)
else:
print(wrong)
while sentence != stored_username[0:] and sentence2!= stored_password[0:]:
trials += 1
print(trials)
(trials <=3 and sign_in())
if trials >= 3:
break
if sentence== stored_username[0:] and sentence2 == stored_password[0:]:
print(Aceppted)
else:
quit()