From 13be77f828c5f2173172dcb74eadd0be5c2c16d2 Mon Sep 17 00:00:00 2001 From: cheeks <134818917+leftovertoast@users.noreply.github.com> Date: Tue, 21 Jan 2025 13:30:46 -0500 Subject: [PATCH] Completed 4-10 Slices --- Chapter_04/4-10_slices.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Chapter_04/4-10_slices.py diff --git a/Chapter_04/4-10_slices.py b/Chapter_04/4-10_slices.py new file mode 100644 index 0000000..ea1f9e5 --- /dev/null +++ b/Chapter_04/4-10_slices.py @@ -0,0 +1,13 @@ +# Excercise 4-10 Slices +# Learning Objective: Slice list for First, Middle, and Last 3 elements of a list respectively. + +numbers = [value for value in range(1, 21)] +print(str(numbers) + "\n") + +print(f"The first three items in the list are: {numbers[0:3]}\n") +print(f"Three items from the middle of the list are: {numbers[9:12]}\n") +print(f"The last three items in the list are: {numbers[-3:]}") + +# 100% this can be done better. + +