Week 5 Exercise 1, Q2

One line creates dictionary. My solution:

data = [('Sumit', 183), ('Rahul', 175), ('Kritika', 170), ('Harshit', 177), ('Deepak', 162)]
dictionary = dict(data) 
print(data_dict)
name = input("enter the name: ")
try:
    print("Height of ", name, "is : ", dictionary[name])
except KeyError: 
    print ("Name is not in the list") 
3 Likes