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:

forward:

and backward:

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

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