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'

You mean you want to add the invalid username and password to the database?

'm trying to make a code for you, but have you realized you use keyword "pass"? which editor/IDE are you using?

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'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.