how to make simple login in python code example

Example 1: how to make simple login in python

username = input(' enter your username: ')
if username == 'Put Your Username Here':#change this
   print("checking username")
   time.sleep(0.5)
   print("username is right") 
   password = input(' type your password: ')
   if password == 'Put Your Password Here':#change this
    time.sleep(0.5) 
   else:
    exit()
else:
 exit()

Example 2: python code for login page

CorrectUsername = surname[0:3] + firstname[0:3]

loop = 'true'
while (loop == 'true'):
    username = input("Please enter your username: ")
    if (username == CorrectUsername):
    	password = input("Please enter your password: ")
        if (password == CorrectPassword):
            print("Logged in successfully as ") + username
            loop = 'false'
        else:
            print "Password incorrect!"
    else:
        print "Username incorrect!"

Tags:

Misc Example