Isn't there a problem in this exercise?


#1


See the code below, I don't understand that middle_third = [8,9,10,11,12,13,14]
Previously, we've been told that in slicing: [start:end:stride]
start = where it starts inclusive
end = where it ends exclusive
stride = the space between items in the sliced list

So why do I get [8,9,10,11,12,13,14] instead of [7,8,9,10,11,12,13] ? Something I'm missing?

to_21 = range(1,22)

odds = to_21[::2]

middle_third = to_21[7:14:1]


#2

What is the index of the first item in a list?


#3

You start at 7, what's at index 7?


#4

Of course we put the indexes and not the items in that slice!

Thanks @ionatan and @appylpye! :wink:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.