Answer the question
In order to leave comments, you need to log in
How does .map work in python?
Started learning python. Let's say there is a function that takes a list of words. How to go through all the elements of this list and for example add a '!' ?
Here in js it is possible through .map , but in python? Explain in more detail please
Answer the question
In order to leave comments, you need to log in
And in Python, you can use map:
words = ['hello', 'world']
with_exclamation = list(map(lambda s: s + '!', words))
with_exclamation = [s + '!' for s in words]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question