Question: using python 4. Given a list containing dictionaries of names such as: simpsons - [{'name': 'Homer'}, {'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Marge'}, {'name': 'Maggie'}] Write
4. Given a list containing dictionaries of names such as: simpsons - [{'name': 'Homer'}, {'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Marge'}, {'name': 'Maggie'}] Write a function that returns a string of the names separated by commas except for the last two names, which should be separated by an ampersand. For example, >>> list_of_names (simpsons): Homer, Bart, Lisa, Marge & Maggie If there is only one dictionary in the list, return that name without any commas or an ampersand. For example, >>> list_of_names([{'name': 'Dracula' }]) Dracula If the list is empty, return None
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
