Stating with
a = ['abc', 'efg', 'hij']
I want to get
a = ['abc!', 'efg!', 'hij!']
But obviously without the use of for elements in a:
...because it is not cleaver and I want to understand more about the map
function and how it passes parameters.
So I try to append a '!'
to all elements of the lists using the map function. But before doing so, append
is a list
method but not a str
method.
b = map(list,a) # gives : a = [['a','b','c'],['d','e','f'],['h','i','j']]
a = map(list.append(['!']), b)
That last map function returns a TypeError:
TypeError: append() takes exactly one argument (0 given)
I wish to know if it is possible to pass parameter to the method used by map
.
Thank.