Python Slice Notation is somehow easy and tough in the same way. Lately, I was doing some competitive programming with Python and I have decided to write a summary of the slice notation, thus there is always a place for a quick check.
So, building the list initially looks like this:
Getting first N values is this:
Getting all but first N values is correspondingly:
Getting last N values:
Getting the value in the 5th position from the back:
Rotating the list is carried out here:
Getting first N values rotated:
Getting up to value N, rotated with a step 2:
Replace the first N values from the list with the given list: