Question: Recall that Python's built-in enumerate(seq) function is a generator that returns two values on each call to next(): the offset of the value and the
Recall that Python's built-in enumerate(seq) function is a generator that returns two values on each call to next(): the offset of the value and the value. E.g.
for offset, value in enumerate("hi!"): print(offset, value) generates the output:
0 h 1 i 2 !
Write a function, my_enumerate(seq) that provides the same functionality WITHOUT calling enumerate(). Be sure to include an automated test to validate your solution.
Hint: Your automated test may compare
list(my_enumerate(your_sequence))
to the expected output. Need to use an unittese to test the code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
