Sunday, 9 May 2021

UserId check:issubset

 The program is to see if a given Userid matches any of the userid in our list. 

Here is the code:


def calluserid(old_idlist):
newid=[] #this is where we save the new input taken from the user.
newid.append(input("Key in your id"))
c = set(newid).issubset(old_idlist) # we are checking if the newid set is a subset of oldid_list set.
#what we mean is that we are checking if the newid/taken id eists in the set of the existing oldid list.

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


b= ["k", "l", "M"] #we are giving our program an old_idlist as b
calluserid(b)

No comments:

Post a Comment