I actually have a question relating to list slicing notation, I think it’s called.
I understand start, stop and step are used, but is “end” also a slice notation? Are these just abstract terms to be used here academically to write a piece of code that, were we to use it, we would replace the notations (start, stop, step, end) with actual indices and step values? I guess not, as they return values, but I can’t seem to find a reference to “end”. I may be conflating some things here. List slicing notations especially are some of the most confusing concepts for me, and any clarification is really appreciated.
I get the two concepts below, but am not sure if I would replace with values or not, my guess is only step requires a value as in the exercise they return the indices?
This is clear and simple. I get accessing lists with [ ].
+---+---+---+---+---+---+ | P | y | t | h | o | n | +---+---+---+---+---+---+ 0 1 2 3 4 5 6 -6 -5 -4 -3 -2 -1
The only thing that starts to throw me off is when we start to use slicing : combined with notation. I even get the below, it’s clear and makes sense.
a[start:stop] # items start through stop-1 a[start:] # items start through the rest of the array a[:stop] # items from the beginning through stop-1 a[:] # a copy of the whole array
These are the main questions that arise from the below exercise.
The [:start] - start at the beginning of the array and end at start.
The [end+1:] **start from the end plus 1 and go the end of the array. **
Both of these I just simply can’t wrap my head around. <<<
cheers for the help folks