New submission from Chas Belov <docor...@sonic.net>:

I found 
https://docs.python.org/3.7/tutorial/controlflow.html#the-range-function 
section 4.3 confusing. The range() Function shows the following example:

>>> for i in range(5):
...     print(i)
...
0
1
2
3
4

[some instructional text]

range(5, 10)
   5, 6, 7, 8, 9

range(0, 10, 3)
   0, 3, 6, 9

range(-10, -100, -30)
  -10, -40, -70

This appears to be an instruction to type, for example:
range(5, 10)
at the prompt, and that the response will be:
   5, 6, 7, 8, 9

leading to a perceived bug when I type at the prompt:
>>> range(5, 10)
and receive the response
range(5, 10)

I ultimately figured out that the example is a shorthand to substitute
range(5, 10)
for the original 
range(5)

>>> for i in range(5, 10):
...     print(i)
...
5
6
7
8
9

It would be less confusing if the example instead read:

----------------------------

Substituting "range(5, 10)" for "range(5)" results in (one number per line)
5, 6, 7, 8, 9

Substituting "range(0, 10, 3)" results in
0, 3, 6, 9

and substituting "range(-10, -100, -30)" results in
-10, -40, -70

---------------------------

such that it is clear that the statements are not meant to be taken as literal 
stand-alone entries to be typed at the prompt but are instead substitutions.

----------
messages: 368817
nosy: docor...@sonic.net
priority: normal
severity: normal
status: open
title: Range tutorial shorthand could be made clearer
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40620>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to