Basic example
Input
enumerate_pairs(['a', 'b', 'c'])
Output
[(0, 'a'), (1, 'b'), (2, 'c')]
Each element is paired with its index in a tuple.
Full lesson preview
Use enumerate to access both the index and value while iterating a sequence.
Problem statement
Task
Examples
Input
enumerate_pairs(['a', 'b', 'c'])
Output
[(0, 'a'), (1, 'b'), (2, 'c')]
Each element is paired with its index in a tuple.
Input format
Output format
Constraints
Samples
Input
enumerate_pairs([10, 20])
Output
[(0, 10), (1, 20)]
Two elements become two (index, value) tuples.