[New-bugs-announce] [issue43076] str.split() indexing issue

Aleksandr Sigalov report at bugs.python.org
Sat Jan 30 03:13:38 EST 2021


New submission from Aleksandr Sigalov <tegridycode at gmail.com>:

The following code ran in Google Colab...

=====================================

import sys

print (sys.version)

string = 'WORD=BIRD\nBIRD\nBIRD'

print(string.split())

print('========')

print(string.split('=')[0][0:3])
print(string.split('=')[1][0:3])

=================================

produces this...

=================================

3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0]
['WORD=BIRD', 'BIRD', 'BIRD']
========
WOR
BIR

=================================

Shouldn't index [0:3] give 4 chars? I looked in the docs and I could not find anything explaining this behavior.

=================================

Thanks.

----------
components: Build
messages: 385975
nosy: tegridycode
priority: normal
severity: normal
status: open
title: str.split() indexing issue
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43076>
_______________________________________


More information about the New-bugs-announce mailing list