Advertisement
Guest User

Untitled

a guest
Apr 15th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. logins = {
  2.     "admin": "admin",
  3.     "mitchsaad": "mitchpass",
  4.     "jeratan": "zeuszeus",
  5.     "scorpio": "reddragon10",
  6.     "chrissaad": "chrispass",
  7.     "simone": "mybabyisawesome"
  8.     }
  9.  
  10. def username_check(user): #Checks if the username exists in the logins dictionary
  11.     check = 0
  12.     for key in logins:
  13.         if user == key:
  14.             check = check + 1
  15.     if check == 1:
  16.         return True
  17.     else:
  18.         return False
  19.  
  20. def password_check(user, userpass): #Checks if the username is correct and then checks the password against the value of that username
  21.     if logins.get(user) == userpass:
  22.         return True
  23.     else:
  24.         return False
  25.  
  26.  
  27. def initialize(): #starts the login
  28.     username = str(raw_input("Username: ").lower())
  29.     if len(username) > 0:
  30.         password = str(raw_input("Pasword: ").lower())
  31.     else:
  32.         print "Please enter your username."
  33.         initialize()
  34.     if len(password) > 0:
  35.         ucheck = username_check(username)
  36.         pcheck = password_check(username, password)
  37.         if ucheck == True and pcheck == True:
  38.             print "Login Successful"
  39.         else:
  40.             print "Your Username or Password may be incorrect"
  41.             initialize()
  42.        
  43.  
  44.  
  45.  
  46. initialize() #run the login
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement