[New-bugs-announce] [issue38247] list(str.split(ch)) Does not print blank elements upon repeating character(ch)

Aman Priyanshu report at bugs.python.org
Sat Sep 21 18:19:50 EDT 2019


New submission from Aman Priyanshu <amanpriyanshusms2001 at gmail.com>:

I have been annoyed by the fact that at multiple where we print list(str.split(ch)) we get empty elements in place of repeated characters (ch).

Example:

####
>>> print(list("Hello World How Are You?".split(" ")))
['Hello', 'World', 'How', 'Are', 'You?']
>>> print(list("Hello World       How Are      You?".split(" ")))
['Hello', 'World', '', '', '', '', '', '', 'How', 'Are', '', '', '', '', '', 'You?']
####

So can it be fixed so that  it gives:

####
>>> print(list("Hello World How Are You?".split(" ")))
['Hello', 'World', 'How', 'Are', 'You?']
>>> print(list("Hello World       How Are      You?".split(" ")))
['Hello', 'World', 'How', 'Are', 'You?']
####

----------
messages: 352955
nosy: AmanPriyanshu
priority: normal
pull_requests: 15902
severity: normal
status: open
title: list(str.split(ch))  Does not print blank elements upon repeating character(ch)
type: enhancement
versions: Python 3.8

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


More information about the New-bugs-announce mailing list