Question: Write a program that asks for name from the user and then asks for a number and stores the two in a dictionary [caled the_dict]


![[caled the_dict] as key-value pair. The program then asks if the user](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3d1924e2cc_92966f3d191e2db3.jpg)
Write a program that asks for name from the user and then asks for a number and stores the two in a dictionary [caled the_dict] as key-value pair. The program then asks if the user wants to enter more data (More data ?y]?) and depending on user choice, either asks for another name-number pair or exits and stores the dictionary key, values in a list of tuples and prints the list. Note: Ignore the case where the name is already in the dictionary. Example: Name: pranshu Number: 517-244-2426 More data (y]? y Name: rich Number: 517-842-5425 More data [y)? y Name: alireza Number: 517-432-5224 More data lv]? n (alireza, 517-432-5224], [pranshu, 517-244-2426], [rich, 517-842-5425)] Code code.py New Full Screen 1 dictlist [] are vard 4 input("Name: ") 5 input ("Number: ") 6 7 input('More data (y)? ) 8 9 # add er to re data, then at 10, for key, value in the_dict. items(): #we store temp (key,value) dictlist.append (temp) 12 13 print(sorted (dictlist))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
