How do I map lists in Python with standard library only?

In Python, you can use the built-in `map()` function to apply a function to all items in a list (or any iterable). The `map()` function returns a map object (which is an iterator), allowing you to iterate over the results.

The general syntax of the `map()` function is:

map(function, iterable)

Here’s an example of how to use `map()` to square each number in a list:

numbers = [1, 2, 3, 4, 5]
squared_numbers = list(map(lambda x: x**2, numbers))
print(squared_numbers)  # Output: [1, 4, 9, 16, 25]

Python map lists higher-order functions functional programming