easy +5 pts

Enumerate with start

Create index-value pairs similar to enumerate, with a customizable starting index.

Write a function `enumerate_with_start(seq, start=0)` that returns a list of pairs `[index, value]` for each element in `seq`, where `index` starts at `start` and increments by 1 for each subsequent element. `seq` can be any iterable (list, tuple, string, etc.). The result should be a list of lists, and the function must not use the built-in `enumerate`.

Constraints

seq is any iterable (including empty). The function should work for any iterable type. The time complexity is O(n) where n is the length of seq.

Example

>>> enumerate_with_start(['a', 'b', 'c'], start=1)
[[1, 'a'], [2, 'b'], [3, 'c']]
>>> enumerate_with_start('hi', 5)
[[5, 'h'], [6, 'i']]
5 points ~5 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use a loop and a counter variable initialized to start.
Append [counter, value] to the result list.
Iterate directly over seq to handle any iterable.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.