I have a list of simple key value pair dictionaries. I want to return all the values
eg.
namelist([ {'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Maggie'} ])
# returns 'Bart, Lisa & Maggie'
whats the solution to this?
I do not understand how to do this. first I have just tried looping through to return each value in the list and it only returns the first item.
def namelist(names):
for i in names:
return i
It only returns:
{name: 'Bart'}
The end result should return: 'Bart, Lisa & Maggie'
I dont even understand why my loop isnt looping through each item in the list, just the first.