I am trying to use the map() function and capitalize all the words in the list.
my_pets = ['sisi', 'bibi', 'titi', 'carla']
def capitalizing(a):
for item in a:
b = item.upper()
return b
print(list(map(capitalizing, my_pets)))
If I run this code, I get the output as following:
['S', 'B', 'T', 'C']
Why is that? Why does the code just runs the first letter and stops for each word?
I already know that the "for" loop/iteration is incorrect to get all the words, I don't need it, but why is this loop runs for the first letter of each word?
Thanks for your assistance in advance.