Length of Dictionary
QUESTION DESCRIPTION
Write a program to get the input of key and value of the element in dictionary.
Display the key-value pair in the python dictionary format and find the length of the dictionary
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.
Write a program to get the input of key and value of the element in dictionary.
Display the key-value pair in the python dictionary format and find the length of the dictionary
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.
n=int(input())
k=[]
v=[]
for i in range(0,n):
a=int(input())
k.append(a)
for i in range(0,n):
b=int(input())
v.append(b)
ke=tuple(k)
va=tuple(v)
di=dict(zip(ke,va))
print("The dictionary is")
print(di)
print("Length of dictionary is")
print(len(di))
Comments
Post a Comment