by The-Toon · 6y ago · 0 comments
To continue to be nit picky with that example, the range function produces an iterable object, which is different from a list.
It makes teaching harder. You really have to work to come up with great examples. But it makes learning easier and there's less correcting to do later.
A teacher is in a position of authoritative trust. As a student, after I learn an example is flawed, I often wonder if I’m just missing some context because I trust the teacher to have gotten it right. In a setting where communication is already established (e.g., a class room) this can be cleared up quickly with a question. In other settings (e.g., reading a text), it can leave me wondering until I reach a much higher level of competence.
There's a similar strategy of building things up and then refactoring when they get bad (this ifelse is getting too big. We could use a dict). But the difference is every step along the way is valid or immediately corrected.
[1] https://psychology.wikia.org/wiki/Principles_of_learning#Pri...
But you may be surprised how many list-like operations `range` supports. Subscripting, `len`, `in`, `.count`, `.index`. It might as well be a tuple.
And if you want to nitpick more, range isn't a function.