search any element in Dictionary

     
j=int(input("Any element to find in dictionary "))      
d={1:2,3:4,5:{11:12},7:8}
l=list(d.values())
k=[]
for i in l:
        if isinstance(i,int):
                k.append(i)
        if isinstance(i,dict):
                l=k.append(list(i.values())[0])    
if j in k:
        print("It is present")  
else:
        print("It is not present")
               

Comments

Popular posts from this blog

Prime Number

star pattern

Basic Calc using Python Tkinter