in python please!

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

in python please!

Post by answerhappygod »

in python please!
In Python Please 1
In Python Please 1 (45.03 KiB) Viewed 9 times
Write a function named create_names_dictionary (initials_list, names_list) which takes a list of initials and a list of names as parameters. The function returns a dictionary by looping through each element in the first and the second list and creating a corresponding key:value item. The 'key' of each item in the dictionary is the initials of the first name and surname, and the 'value' is the name (e.g. key of 'AW', value of 'Alex Wong'). For example, the following code: ['Abby Anderson', 'Bella Campbell'] names_list = initials = ['AA', 'BC'] ames_list) my_dictionary create_names_dictionary(initials, names_ print(my_dictionary) produces {'AA': 'Abby Anderson', 'BC': 'Bella Campbell'} You can assume that both parameters are the same length and that the initials_list does not contain any duplicates. For example: Test Result names_list ['Abby Anderson', 'Bella Campbell', 'Charlotte Donovan'] AA Abby Anderson initials = ['AA', 'BC', 'CD'] BC Bella Campbell my_dictionary create_names_dictionary(initials, names_list) CD Charlotte Donovan for letter in sorted (my_dictionary.keys()): print(letter, my_dictionary [letter])
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply