[issue22553] Diagram issue

2014-10-04 Thread Eric Fulton

New submission from Eric Fulton:

I believe the diagram showing how slices works from 
https://docs.python.org/2/tutorial/introduction.html is incorrect.  There 
should be no 6.  

 word = 'Python'
 word[6]
IndexError: string index out of range


Original:
 +---+---+---+---+---+---+
 | P | y | t | h | o | n |
 +---+---+---+---+---+---+
 0   1   2   3   4   5   6
-6  -5  -4  -3  -2  -1

What it should be:
 +---+---+---+---+---+---+
 | P | y | t | h | o | n |
 +---+---+---+---+---+---+
 0   1   2   3   4   5   
-6  -5  -4  -3  -2  -1


--

One way to remember how slices work is to think of the indices as pointing 
between characters, with the left edge of the first character numbered 0. Then 
the right edge of the last character of a string of n characters has index n, 
for example:

 +---+---+---+---+---+---+
 | P | y | t | h | o | n |
 +---+---+---+---+---+---+
 0   1   2   3   4   5   6
-6  -5  -4  -3  -2  -1

--
assignee: docs@python
components: Documentation
messages: 228464
nosy: Eric.Fulton, docs@python
priority: normal
severity: normal
status: open
title: Diagram issue

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22553
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22553] Diagram issue

2014-10-04 Thread Georg Brandl

Georg Brandl added the comment:

Hi Eric,

this paragraph is about slices, where you *can* do

 word[0:6]
'Python'

As such, the paragraph is correct.

--
nosy: +georg.brandl
resolution:  - not a bug
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22553
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com