[docs] question about the documentation

Samuel Lee Duncan sduncan at gsu.edu
Thu May 11 12:29:19 EDT 2017



Your documentation states:
In addition to indexing, slicing is also supported. While indexing is used to obtain individual characters, slicing allows you to obtain substring:
>>>
>>> word[0:2]  # characters from position 0 (included) to 2 (excluded)
'Py'
>>> word[2:5]  # characters from position 2 (included) to 5 (excluded)
'tho'



However, for slicing, doesn't it appear to work better if it stated
Using 'python'  for the word.

Word[0:2]  # return 2 characters and show me the characters starting at the "0" position

-          Returns 'py'  p is position 0, and py are 2 chars
Word[2:5] # return 5 characters and show me the characters starting at the "2" position

-          Returns 'tho'  "o" is the 5th character to be returned (1-based), and "t" is the character at the "2" position (0-based)
Word[3:5]  # return 5 characters and show me the characters starting at the "3" position

-          Returns 'ho'  "o" is the 5th character to be returned (1-based) and "h" is the character at the "3" position (0-based)
Word[5:5]  # return 5 characters and show me the characters starting at the "5" position

-          Returns ' '  - this may be a bug - should throw an error saying the index has been exceeded?
Word [4:5] # return 5 characters and show me the characters starting at the "4" position

-          Returns 'o' - "o" is the 5th character to be returned (1-based) and "o" is the character at the 4th position (0-based)
Word[3:4]

-          Returns 'h' - "h" is the 4th character to be returned (1-based) and "h" is the character at the 3rd position (0-based in the original word 'python')



Sincerely,



[SamNoManagerSignature]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20170511/07291580/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 22030 bytes
Desc: image001.jpg
URL: <http://mail.python.org/pipermail/docs/attachments/20170511/07291580/attachment-0001.jpg>


More information about the docs mailing list