Advanced topics in python 10. stride length


I’m getting the error to_one_hundred should include 0, but does not. Everything looks right, and the console does what the exercise asks for.


to_one_hundred = range(101)
backwards_by_tens = to_one_hundred[101:0:-10]
print backwards_by_tens

<do not remove the three backticks above>


if we look at the output:

[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]

0 is indeed not included, your list slicing has 3 values:

start: 101
stop: 0
stride: -10

the problem is that the stop value is not included, values greater then (>) the stop value, yes. But not the stop value itself.


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