What is the best way to set a start index when iterating a list in Python. For example, I have a list of the days of the week - Sunday, Monday, Tuesday, ... Saturday - but I
Why are people using list slicing (slow because it copies to a new list), importing a library function, or trying to rotate an array for this?
Use a normal for-loop with range(start, stop, step)
(where start
and step
are optional arguments).
For example, looping through an array starting at index 1:
for i in range(1, len(arr)):
print(arr[i])