in python please!
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])
in python please!
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am