Define a function mymap(func, seq) that applies the function func to each element of the sequence seq and returns a new list containing the results.

def mymap(func, seq):
    """Map func over seq.

    >>> mymap(lambda x: x * 2, [1, 2, 3])
    [2, 4, 6]
    >>> mymap(str, [1, 2, 3])
    ['1', '2', '3']
    """
Criteria
numbers = [1, 2, 3, 4, 5]
squared = list(map(lambda x: x ** 2, numbers))
print(squared)  # Output: [1, 4, 9, 16, 25]

Updated: