How I use dictonaries to basic login ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How I use dictonaries to basic login ?

I try but ı can not combine passwords and usernames.I need elementary code..

17th Jan 2018, 9:45 PM
captainflint
captainflint - avatar
4 Answers
+ 6
Check my answer again, I updated it with a link to a code
17th Jan 2018, 10:37 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
It's a key:value structure, so you have to go with something like this: users = {'jack44': 's3jx5', 'jill33': 'gsk4!', 'mary.lou': 'mama99'} login = input('Enter your login: ') pwd = input('Enter your password: ') if login in users: if users[login] == pwd: print('Welcome', login) else: print('Wrong credentials. The police is on its way 🚓') else: print('Sorry, no such user exists.') https://code.sololearn.com/cL6i8GOXOVRw/?ref=app
17th Jan 2018, 9:57 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
thank you bro you re awesomee <3 :)))
17th Jan 2018, 10:03 PM
captainflint
captainflint - avatar
0
ı did your codes but ı take str error.why ??
17th Jan 2018, 10:18 PM
captainflint
captainflint - avatar