Python: How to shift values in a list

To shift values in a list (replace the value at the first place of the list to its last place and vice versa), you need to rearrange the list with two slices.

The shift for the list:


and backward:

If a cyclic shift is necessary, repeat this command the required number of times in “for” cycle.

5 3 votes
Article Rating
Notify of
0 Комментарий
Inline Feedbacks
View all comments