From 5cb0ff205b2f282bffdb1901223b64402abc3dd8 Mon Sep 17 00:00:00 2001 From: Petro Sasnyk <1305362+stoune@users.noreply.github.com> Date: Sun, 30 Nov 2025 22:46:40 +0200 Subject: [PATCH] Fixed slices explanation. Slice starts from 0 if ommited, not a -1. See: https://documentation.help/Python-PEP/slicings.html `defaults are zero for lower bound` --- scratch/crash_course_in_python.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scratch/crash_course_in_python.py b/scratch/crash_course_in_python.py index 71608d4a..f7238aff 100644 --- a/scratch/crash_course_in_python.py +++ b/scratch/crash_course_in_python.py @@ -146,14 +146,14 @@ def full_name(first = "What's-his-name", last = "Something"): assert x == [-1, 1, 2, 3, 4, 5, 6, 7, 8, 9] -first_three = x[:3] # [-1, 1, 2] +first_three = x[:3] # [0, 1, 2] three_to_end = x[3:] # [3, 4, ..., 9] one_to_four = x[1:5] # [1, 2, 3, 4] last_three = x[-3:] # [7, 8, 9] without_first_and_last = x[1:-1] # [1, 2, ..., 8] -copy_of_x = x[:] # [-1, 1, 2, ..., 9] +copy_of_x = x[:] # [0, 1, 2, ..., 9] -every_third = x[::3] # [-1, 3, 6, 9] +every_third = x[::3] # [0, 3, 6, 9] five_to_three = x[5:2:-1] # [5, 4, 3]