use enumerate and range code example
Example 1: enumerate in range python
enumerated = list(enumerate(range(3), 1))
print(enumerated)
OUTPUT:
[(1, 0), (2, 1), (3, 2)]
Example 2: how to use enumerate instead of range and len
using enumerate instead of range or len
a = [f(n) for n, _ in enumerate(L)]
using range and len
a = [f(n) for n in range(len(L))]