0

See I've made a short little login that works with a dictionary, but I don't know how to add something to the dictionary while the program is running, so if you know how to fix this can you please help. Much apperciated.

database = {'name1': '1234', 'name2': '5678', 'name3': '9012'}

name = raw_input('Enter username: ')

pass = raw_input('Enter password: ')

if pass in database[name]:
       print 'Welcome', name
else:
      pirnt 'Invalid password or username'
3
Contributors
3
Replies
6
Views
8 Years
Discussion Span
Last Post by Stefano Mtangoo
0
database = [('name1','1234'), ('name2', '5678'), ('name3', '9012')]

name = raw_input('Enter username:\n ')

passwd = raw_input('Enter password:\n ')
found = False
for usrname, password in database:
   if((name==usrname) and (password==passwd)):
      print 'Welcome', name
      found = True
      break;

if(not found):
   print 'Invalid password or username'
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.