The solution for "How Large is a Slice?" says the the expression values[low:high], or possibly high - low, will only work if high is less than the total length of the list values. This isn't quite correct on either interpretation.
As shown in Episode 2, values[low:high] will always return a list, even if one or both of the limits are out of bounds. The length of the slice will be high - low if and only if high is equal to or less than the length of the list; it will be zero if both high and low are greater than the length of the list, and somewhere in between otherwise.
This pull request suggests alternative wording that I think would be clearer and more accurate.
The solution for "How Large is a Slice?" says the the expression
values[low:high]
, or possiblyhigh - low
, will only work ifhigh
is less than the total length of the listvalues
. This isn't quite correct on either interpretation.As shown in Episode 2,
values[low:high]
will always return a list, even if one or both of the limits are out of bounds. The length of the slice will behigh - low
if and only ifhigh
is equal to or less than the length of the list; it will be zero if bothhigh
andlow
are greater than the length of the list, and somewhere in between otherwise.This pull request suggests alternative wording that I think would be clearer and more accurate.