Square numbers
Input
map_list([1, 2, 3], lambda x: x * x)
Output
[1, 4, 9]
Each element is replaced by its square.
Full lesson preview
Apply a function to each element of a list and return a new list of results.
Problem statement
Task
Examples
Input
map_list([1, 2, 3], lambda x: x * x)
Output
[1, 4, 9]
Each element is replaced by its square.
Input format
Output format
Constraints
Samples
Input
map_list(['a','b'], lambda s: s.upper())
Output
['A', 'B']
Each string is converted to uppercase.