[Python-ideas] string method count()

Steven D'Aprano steve at pearwood.info
Wed Apr 25 17:33:53 EDT 2018


On Wed, Apr 25, 2018 at 11:22:24AM -0700, Julia Kim wrote:
> Hi,
> 
> There’s an error with the string method count().
> 
> x = ‘AAA’
> y = ‘AA’
> print(x.count(y))
> 
> The output is 1, instead of 2.

Are you proposing that there ought to be a version of count that looks 
for *overlapping* substrings?

When will this be useful?


-- 
Steve


More information about the Python-ideas mailing list