← Python Intermediate
6 / 25
Lesson 6 — Lambda & map
Tiny functions
A lambda is a short function without a name: lambda x: x + 1 takes x and returns x + 1. map(fn, items) applies a function to every item. It returns a lazy map object, so wrap it in list() to see the results.
words = ["a", "b"]
print(list(map(lambda w: w.upper(), words))) # ['A', 'B']
Why it matters: lambdas are handy whenever a function needs another small function — for map, sort keys and filters.
Want it another way?
Task
Use map with a lambda to double each number and print the list.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.