Teaching the "range" function in Python 3

Christian Gollwitzer auriocus at gmx.de
Sat Jul 1 01:48:12 EDT 2017


Am 30.06.17 um 04:33 schrieb Rick Johnson:
> And to further drive home the point, you can manually insert
> a list literal to prove this:
> 
>      >>> range(10)
>      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>      >>> for value in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
>      ...     print(value)
>      ...
>      0
>      1

Now you have exactly missed the point that the OP was asking about. In 
Python 2, yes, this works and it is the way he has teached it to his 
students. Howver, in Python 3:

 >>> range(10)
range(0, 10)

This is not helpful to understand what range does, and this is the 
original question.

	Christian



More information about the Python-list mailing list