14 lines
432 B
Python
14 lines
432 B
Python
# 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.
|
|
|
|
|