Map

def get_length(a):
    return len(a)


def my_map(func, my_list):
    i = 0
    length_list = []
    while i < len(my_list):
        x1 = func(my_list[i])
        length_list.append(x1)
        yield length_list
        i += 1


x = my_map(get_length, ['orange', 'apple', 'strawberry'])

print(next(x))
print(next(x))
print(next(x))

Related Posts

Join the Discussion

Your email address will not be published. Required fields are marked *

Back to top