Monday, 10 May 2021

How to make a program for Login functionality.

 How to make a program for Login functionality. 

 

#now if you copy and paste these codes into your jupyter notebook or pycharm, the code should run. 


def calluserid(old_idlist):
    n_passid= {} #this is where we save the new input taken from the user.
    k= input("give me a userid")
    y= input("give me a pass")
    n_passid.update({(k) : (y)})

# i'm passing in k's value as the key for the new dict and y as the value of the key k.  
    
    
    test = n_passid.items() <= old_idlist.items() # we are checking if 'user log in credential' items in the n_passid dictionary exits in the oldid_list set.

#another way of doing this is using issubset. use: #set(n_passid.items()).issubset(set(old_idlist.items()))


    #what we mean is that we are checking if the newid and pass/login credentials exists in the dictionary of the existing oldid list.

    if (test):
        print("welcome") #if the c is true, print welcome or else try again
    else:
        print("try again")
        calluserid(old_idlist)   

a= {"sihan" : "123", "joe" : "456"} #our user id and password database. we saved the passwords and userids in the database called a. so we are comparing against a.
       
calluserid(a)



 

No comments:

Post a Comment