HomeReview of Python Basics Write a Python script to check if a given key already exists in a dictionary. 1 Comments Facebook Twitter Q. Write a Python script to check if a given key already exists in a dictionary.Answer =Dictionary have unique key only. So this program is not possible.
d={1:10,2:20,3:30} a=int(input("Enter key you want to search for-")) if a in d: print(a,"key is present in dictionary") else: print(a,"key is not present in dictionary")
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )