How does `s[start:stop:step]` carve a substring out of a string — and which single step value flips it backward?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
You are given word = "mango". Extract its first character with square-bracket
indexing and assign it to first_char. Remember: indexing starts at 0.
Zero-based and negative positions
For s = "abc" write s[0], s[1], s[2], give s[-1] and s[len(s) - 1] as "c", and record s[3] and s[-4] raising an IndexError.
s[start:stop:step] stopping before stop
Give the meaning of each of the three numbers, state that a lone pair defaults the step to 1, and evaluate s[3:6] and s[3:6:2] on s = "abcdefgh".
Negative steps and the empty result
Record s[:] as a full copy and s[::-1] as the reversal, walk s[4:1:-2] character by character to "ec", and give s[6:3] as "".