QUESTION DESCRIPTION
Write a program to check whether the given key is present in the dictionary.
If the key is present then display the value of the entered key and if the key is not present then display the appropriate message
Input:
1.Get two dictionaries key-value elements
2. Get the key value to be searched
Output:
1. Display the first dictionary
2. Display the second dictionary
3. Display the concatenated dictionary
4. Display whether the key is present or nor and the respective value of the key.
Write a program to check whether the given key is present in the dictionary.
If the key is present then display the value of the entered key and if the key is not present then display the appropriate message
Input:
1.Get two dictionaries key-value elements
2. Get the key value to be searched
Output:
1. Display the first dictionary
2. Display the second dictionary
3. Display the concatenated dictionary
4. Display whether the key is present or nor and the respective value of the key.
a=int(input())
b=int(input())
c=int(input())
d=int(input())
di1={a:b}
di2={c:d}
print("First Dictionary")
print(di1)
print("Second Dictionary")
print(di2)
di3={**di1,**di2}
print("Concatenated dictionary is")
print(di3)
s=int(input())
flag=0
for k,v in di3.items():
if k==s:
print("Key is present and value of the key is")
print(v)
flag=1
if flag==0:
print("Key not present")
Comments
Post a Comment