Enumerate step

Asked 2 years ago, Updated 2 years ago, 24 views

The list is looped using steps, but the value of n increases by 1 instead of step when enumerate and use.

Does enumerate not support steps?

a = range(0, 20)
for n, i in enumerate(a[::5]):
    print(n)
>> 0
1
2
3

# Desired Value
>> 0
4
9
13

python

2022-09-20 10:39

1 Answers

Enumerate itself means "numbering." You can specify the starting number, but there are no steps.


2022-09-20 10:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.