Exercise told me to return different result depending from “start”. If it’s empty I have to return a different value than if it’s not empty. So far in this course I have not been thaught any other method of testing. Is there any other method of doing this without testing?
There’s no reason to test if you use range
You’d return the range.
Note that what your function does is to create a range. That’s what range does, range fully implements this already, there is no more work to be carried out, you would do only this:
def f(start):
return range(start, 101, 3)
IF you use range, then anything in addition to this is doing nothing.
(the point of the exercise is probably to implement it yourself though, so that would mean doing it without range ie. you’d start with… start, and an empty list, and then begin appending values to your list and incrementing the current value by 3 each time and repeating this until you reach the upper bound at which point you’d be done and ready to present the result)
That says how the function should behave, it doesn’t say anything about requiring code to be dedicated to it.
Since range already behaves that way there would be nothing further you would need to do
Oh, that’s good to know, thanks. I don’t think this was covered in any lesson so far. I also checked Python 3 lists PDF we got in the end of lists lessons and this info is also not there.
Especially when a learner is glossing over the documentation and expects everything to be spelled out in the lesson. We have yet to see new learners do this exercise without using an if statement. Perhaps if the lesson spelled out things as you have above, it would foster greater intuition.