One option is a list comprehension:

[add(x, 2) for x in [1, 2, 3]]

More options:

a = [1, 2, 3]

import functools
map(functools.partial(add, y=2), a)

import itertools
map(add, a, itertools.repeat(2, len(a)))
Answer from Sven Marnach on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-lambda-anonymous-functions-filter-map-reduce
Python Lambda Functions - GeeksforGeeks
Explanation: lambda function doubles each number and map() iterates through a and applies the transformation. 6. reduce(): This function repeatedly applies a lambda expression to elements of a list to combine them into a single result.
Published ย  May 18, 2026
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-map-with-lambda
Python map with Lambda - GeeksforGeeks
July 23, 2025 - a = [1, 2, 3, 4, 5] # Use map() with a lambda function to multiply each element in the list 'a' by 3 multiplied = map(lambda x: x * 3, a) print(list(multiplied))
Discussions

Differences between lambda and .map()
Not the same at all. lambda is just a way to define a function. These two do the same thing: def foo(x): return x ** 2 foo = lambda x: x ** 2 This is useful in situations where you just want a one-off throwaway function - let's say you have a list of people: @dataclass class Person: first_name: str last_name: str pythons = [ Person("John", "Cleese"), Person("Terry", "Gilliam"), Person("Eric", "Idle"), Person("Michael", "Palin"), Person("Graham", "Chapman"), Person("Terry", "Jones") ] And you want to sort them by their last name. You could write this: def get_last_name(person): return person.last_name pythons.sort(key=get_last_name) But you know you're probably not going to need that function anywhere else, so you can just inline it as a lambda: pythons.sort(key=lambda p: p.last_name) More on reddit.com
๐ŸŒ r/learnpython
23
19
March 13, 2020
python - How to do multiple arguments to map function where one remains the same - Stack Overflow
By wrapping the function call with a lambda and using the star unpack, you can do map with arbitrary number of arguments. ... I's quite mysterious you got so much upvotes by not answering the question, which is about using a constant argument for the function referenced in map. Let me add mine just for the fun. Here is a valid answer. 2023-03-05T09:17:16.263Z+00:00 ... To pass multiple ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Send two argument using map and lambda functions and return two values - Stack Overflow
That said, in your particular case you don't need a lambda, for example, you can do: Copyfrom future_builtins import map # Only on Py2; Py3 map is good from itertools import repeat model = ... initialize a model that will be passed to every call ... hnd = map(function_f, list_value, repeat(model)) or just use a generator expression (unless the function is a Python ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Unleashing the Power of Lambda Functions in Python: Map, Filter, Reduce
Lambda is Nice. Sometimes, I think a simple list comprehension may look a bit more neat though, even = [k for k in numbers if k%2==0] More on reddit.com
๐ŸŒ r/pythontips
5
20
July 22, 2023
๐ŸŒ
Stanford CS
cs.stanford.edu โ€บ people โ€บ nick โ€บ py โ€บ python-map-lambda.html
Python Map Lambda
As a companion to map(), the filter() function takes a function and a list, and returns a subsetted list of the elements where the function returns true. For example, given a list of strings, return a list of the strings where the length is greater than 3: >>> strs = ['apple', 'and', 'a', 'donut'] >>> >>> list(filter(lambda s: len(s) > 3, strs)) ['apple', 'donut']
๐ŸŒ
Learn Coding Fast
learncodingfast.com โ€บ home โ€บ python map() function โ€“ how to map a function with multiple arguments
Python map() function โ€“ How to map a function with multiple arguments | Learn Coding Fast
November 6, 2020 - To map a function with multiple arguments in Python, we need to pass multiple iterables to the map() function. In today's post, we'll learn toโ€ฆ
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ differences between lambda and .map()
r/learnpython on Reddit: Differences between lambda and .map()
March 13, 2020 -

I'm looking to expand my knowledge on the subject these upcoming days and was hoping someone could shed some clarity. Lambda escapes me sometimes because I THINK I understand, but then when I look at it in practice I get the cold fingers.

What I was wondering is if there was any similarity between the two? They look to me that they accomplish similar tasks. I'm not sure if they're the same thing or can be made into the same thing or if they're different? I was also looking at both of them and wondering if they're pretty much synonymous with a "for" loop?

Top answer
1 of 3
17
Not the same at all. lambda is just a way to define a function. These two do the same thing: def foo(x): return x ** 2 foo = lambda x: x ** 2 This is useful in situations where you just want a one-off throwaway function - let's say you have a list of people: @dataclass class Person: first_name: str last_name: str pythons = [ Person("John", "Cleese"), Person("Terry", "Gilliam"), Person("Eric", "Idle"), Person("Michael", "Palin"), Person("Graham", "Chapman"), Person("Terry", "Jones") ] And you want to sort them by their last name. You could write this: def get_last_name(person): return person.last_name pythons.sort(key=get_last_name) But you know you're probably not going to need that function anywhere else, so you can just inline it as a lambda: pythons.sort(key=lambda p: p.last_name)
2 of 3
7
lambda is just a different syntax for defining functions. The following line of code: f = lambda x, y: x + y is essentially equivalent to: def f(x, y): return x + y The important thing about lambda is that you can use it in the middle of an expression. It's often helpful when a function takes a function as an argument (e.g. the key argument to list.sort), and you want to pass in a really simple function like the above. But you can always avoid using lambdas if you don't like them. And you can only use them to define functions that consist of a single expression. map is for when you want to call a function many times with multiple arguments. For example: mylist = [3, -4, 2, 78, -18] for num in map(abs, mylist): print(num) This is equivalent to: for num in mylist: print(abs(num)) map returns a generator, so instead of calling the function many times immediately, it waits until something actually tries to iterate over it. You can therefore use it on an infinite generator such as itertools.count. You can generally replace map with a for loop as above, or with a generator expression (e.g. (abs(num) for num in mylist)). You can pick which one you prefer, or you can mix and match them depending on the circumstances.
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ map-function
Python Map Function: Streamline Data Transformation Efforts
... numbers = [1, 2, 3, 4, 5] squared_numbers = map(lambda x: x**2, numbers) print(list(squared_numbers)) # Outputs: [1, 4, 9, 16, 25] # Using lambda with multiple sequences numbers1 = [1, 2, 3] numbers2 = [4, 5, 6] added_numbers = map(lambda x, y: x + y, numbers1, numbers2) print(list(add...
Find elsewhere
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Apply a Function to Items of a List in Python: map() | note.nkmk.me
May 15, 2023 - ... It is also possible to define a function with def and specify it as the first argument of map(). ... You can specify multiple iterables in map() like map(function, iterable1, iterable2, ...).
Top answer
1 of 2
6

Since you say you only want a single model, not a new model for each value, this is fairly simple. Change:

hnd = map(lambda (valua): function_f(valua), list_value)

to:

model = ... initialize a model that will be passed to every call ...
hnd = map(lambda valua: function_f(valua, model), list_value)

Just make sure function_f returns both the new value and model, e.g. if it previously did:

def function_f(val, model):
    ... calculate newval and make newmodel ...
    return newval

just change it to:

def function_f(val, model):
    ... calculate newval and make newmodel ...
    return newval, newmodel

Note: If need to use lambdas to use map, don't use map; it gains you nothing (a generator expression or list comprehension is going to run with the same speed or even faster in most cases where the mapping function isn't a CPython built-in). That said, in your particular case you don't need a lambda, for example, you can do:

from future_builtins import map  # Only on Py2; Py3 map is good

from itertools import repeat

model = ... initialize a model that will be passed to every call ...
hnd = map(function_f, list_value, repeat(model))

or just use a generator expression (unless the function is a Python built-in implemented in C, map basically never gains you performance; if you don't want to think about whether map is appropriate, always using list comprehensions/generator expresssions instead of map is a good idea):

# Change outside parens to brackets, [], for list comp
hnd = (function_f(x, model) for x in list_value)
2 of 2
3

By using zip, you can use map with such function. I am providing a sample code as you have asked to demonstrate

ls1 = [1,2,3,4,5]
ls2 = [1,2,3,4,5]
>>> def func(x,y):
    return x+1,y+1

>>> map(lambda (v1, v2): func(v1, v2), zip(ls1, ls2))
[(2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-pass-multiple-arguments-to-map-function
Python - pass multiple arguments to map function - GeeksforGeeks
September 13, 2022 - Passing Multiply function, list1, list2 and list3 to map(). The element at index 0 from all three lists will pass on as argument to Multiply function and their product will be returned.
๐ŸŒ
ZetCode
zetcode.com โ€บ python โ€บ python-map
Python map - presenting Python map function
January 29, 2024 - In the next example, we show how to use multiple functions in Python map. ... #!/usr/bin/python def add(x): return x + x def square(x): return x * x nums = [1, 2, 3, 4, 5] for i in nums: vals = list(map(lambda x: x(i), (add, square))) print(vals)
๐ŸŒ
Real Python
realpython.com โ€บ python-lambda
How to Use Python Lambda Functions โ€“ Real Python
December 1, 2023 - Outside of the Python interpreter, this feature is probably not used in practice. Itโ€™s a direct consequence of a lambda function being callable as it is defined. For example, this allows you to pass the definition of a Python lambda expression to a higher-order function like map(), filter(), or functools.reduce(), or to a key function.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ how-to-use-the-python-map-function
Ultimate Guide to Python Map Function for Data Processing | DigitalOcean
December 18, 2024 - The map() function in Python takes a function and one or more iterables and returns an iterator that applies the given function to each element of the provided iterables. In other words, it โ€œmapsโ€ the function across each item in the iterable. For example: numbers = [1, 2, 3, 4] squares ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ lambda-functions-in-python
Lambda Functions in Python โ€“ How to Use Lambdas with Map, Filter, and Reduce
June 14, 2024 - Explanation: In this code, we use a lambda function to define a small, anonymous function that takes each pair of numbers and prints their multiplication. The map function applies this lambda function to each pair (tuple) in the list. Wrapping ...
๐ŸŒ
Reddit
reddit.com โ€บ r/pythontips โ€บ unleashing the power of lambda functions in python: map, filter, reduce
r/pythontips on Reddit: Unleashing the Power of Lambda Functions in Python: Map, Filter, Reduce
July 22, 2023 -

Hello Pythonistas!

I've been on a Python journey recently, and I've found myself fascinated by the power and flexibility of Lambda functions. These anonymous functions have not only made my code more efficient and concise, but they've also opened up a new way of thinking about data manipulation when used with Python's built-in functions like Map, Filter, and Reduce.

Lambda functions are incredibly versatile. They can take any number of arguments, but can only have one expression. This makes them perfect for small, one-time-use functions that you don't want to give a name.

Here's a simple example of a Lambda function that squares a number:

square = lambda x: x ** 2

print(square(5)) # Output: 25

But the real power of Lambda functions comes when you use them with functions like Map, Filter, and Reduce. For instance, you can use a Lambda function with `map()` to square all numbers in a list:

numbers = [1, 2, 3, 4, 5]

squared = list(map(lambda x: x ** 2, numbers))

print(squared) # Output: [1, 4, 9, 16, 25]

You can also use a Lambda function with `filter()` to get all the even numbers from a list:

numbers = [1, 2, 3, 4, 5]

even = list(filter(lambda x: x % 2 == 0, numbers))

print(even) # Output: [2, 4]

And finally, you can use a Lambda function with `reduce()` to get the product of all numbers in a list:

from functools import reduce

numbers = [1, 2, 3, 4, 5]

product = reduce(lambda x, y: x * y, numbers)

print(product) # Output: 120

Understanding and using Lambda functions, especially in conjunction with Map, Filter, and Reduce, has significantly improved my data manipulation skills in Python. If you haven't explored Lambda functions yet, I highly recommend giving them a try!

Happy coding!

๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ python map() with lambda function
Python map() with Lambda Function - Spark By {Examples}
May 31, 2024 - Using lambda with map() function is the most common way of usage in Python to perform transformations on iterable objects (e.g., list, tuple, set). What
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-map-function
Python map() function - GeeksforGeeks
Explanation: lambda x: x ** 2 squares each number and the results are converted into a list. We can use map() with multiple iterables if the function we are applying takes more than one argument.
Published ย  3 weeks ago
๐ŸŒ
Caasify
caasify.com โ€บ home โ€บ blog โ€บ master python map function: use lambda & user-defined functions
Master Python Map Function: Use Lambda & User-Defined Functions
October 17, 2025 - The map() function in Python is used to apply a specific function to each item in a collection, like a list or dictionary. It returns an iterator with the results of applying the function to each element.
๐ŸŒ
Python Tips
book.pythontips.com โ€บ en โ€บ latest โ€บ map_filter.html
4. Map, Filter and Reduce โ€” Python Tips 0.1 documentation
Most of the times we use lambdas with map so I did the same. Instead of a list of inputs we can even have a list of functions! def multiply(x): return (x*x) def add(x): return (x+x) funcs = [multiply, add] for i in range(5): value = list(map(lambda x: x(i), funcs)) print(value) # Output: # [0, 0] # [1, 2] # [4, 4] # [9, 6] # [16, 8] As the name suggests, filter creates a list of elements for which a function returns true.
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ built-in-methods โ€บ map-method-in-python
Python map() Method - AskPython
January 25, 2026 - The first argument accepts any callable function, including built-in functions, lambda expressions, or custom functions. The second argument accepts any iterable object like lists, tuples, strings, or dictionaries. When you call map(), Python doesnโ€™t immediately process your data. Instead, it returns a map object that computes values only when you request them. This lazy evaluation approach saves memory, particularly when working with large datasets that donโ€™t fit into RAM at once. def multiply_by_ten(n): return n * 10 numbers = [1, 2, 3, 4, 5] result = map(multiply_by_ten, numbers) print(result) # <map object at 0x7f8b8c0d1d90> print(list(result)) # [10, 20, 30, 40, 50]