def ups(*name):
for n in name:
a=n.upper()
return a
lis=["lan","ona"]
m=list(map(ups,lis))
print(m)
Here in the map I have not done unpacking of the list, but the same in case of function call for without Map(), (eg) like ups(*lis)
is must, why is that?
Learning, Thanks
In addition to ksourav's answer,
map(function, iterable, ...)
"Return[s] an iterator that applies function to
every item of iterable, yielding the results". As ksourav points out
in his answer, the items you pass are strings and thus iterables
themselves - so the function just returns the last letter in
uppercase, likes = 'lan'
for char in s:
print(char.upper())
# L
# A
# N
tuple
and not the individual elements of
the string anymore. This is why here, your function returns
the whole word in uppercase letters, liket = ('lan',)
for element in t:
print(element.upper())
# LAN
m = list(map(lambda x: x.upper(), lis))
# or even better
m = [s.upper() for s in lis]