The program creates a dictionary d with two key-value pairs "Name" and "Age". The variable i is assigned the value "City". An if statement checks if the value of i is present as a key in the dictionary d using the in operator. If i is found in d, the program prints "Key is Available in the Dictionary". If i is not found in d, the program prints "Key is not Available in the Dictionary". In this case, since "City" is not a key in d, the program will print "Key is not Available in the Dictionary". In summary, the program demonstrates how to check if a key is present in a dictionary in Python using the in operator.
d = {"Name":"Ram" , "Age":23} """ if "Name" in d: print('Key is Available in the Dictionary') else: print('Key is not Available in the Dictionary') """ i="City" if i in d: print('Key is Available in the Dictionary') else: print('Key is not Available in the Dictionary')
Key is not Available in the Dictionary
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions