This a question on coursera practices excess.
Create a new list using the 9th through 12th elements (four items in all) of new_lst and assign it to the variable sub_lst.
link to the question: https://runestone.academy/runestone/books/published/fopp/Sequences/TheSliceOperator.html The last question on the list.
How is my code
new_lst = ["computer", "luxurious", "basket", "crime", 0, 2.49, "institution", "slice", "sun",
["water", "air", "fire", "earth"], "games", 2.7, "code", "java", ["birthday", "celebration", 1817,
"party", "cake", 5], "rain", "thunderstorm", "top down"]
new_lst = new_lst[9:12]
sub_lst = new_lst
print(sub_lst)
My output:
[['water', 'air', 'fire', 'earth'], 'games', 2.7]
But here is the expected output:
['sun', ['water', 'air', 'fire', 'earth'], 'games', 2.7]
Please why am I not getting the expected output?
new_lstin the process? You should have assigned the slice directly tosub_lstinstead.