Completed 4-10 Slices
This commit is contained in:
parent
c269e0c345
commit
13be77f828
13
Chapter_04/4-10_slices.py
Normal file
13
Chapter_04/4-10_slices.py
Normal file
@ -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.
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user