Enumerate

def my_enumerate(my_list):
    i = 0
    finite_list = []
    my_tuple = ()
    while i < len(my_list):
        my_tuple = my_tuple + (str(len(my_list[i])), )
        my_tuple = my_tuple + (my_list[i], )
        finite_list.append(my_tuple)
        yield finite_list
        i += 1
        my_tuple = ()


x = my_enumerate(["apple,", "orange", "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