Exercise: Enumerating
Define a function myenumerate(seq) that takes a sequence seq and returns a
list of tuples, where each tuple contains an index and the corresponding element
from the sequence.
def myenumerate(seq):
"""Enumerate seq into a list of (index, item) tuples.
>>> myenumerate(['a', 'b', 'c'])
[(0, 'a'), (1, 'b'), (2, 'c')]
>>> myenumerate([10, 20, 30, 40])
[(0, 10), (1, 20), (2, 30), (3, 40)]
"""
Library
items = ['a', 'b', 'c']
enumerated_items = list(enumerate(items))
print(enumerated_items) # Output: [(0, 'a'), (1, 'b'), (2, 'c')]