[Python-ideas] string method count()

Alexandre Brault abrault at mapgears.com
Wed Apr 25 14:27:59 EDT 2018


str.count counts non-overlapping instances of the substring. After
counting the first 'AA', there is only one A left, so that isn't a
second instance of 'AA'


On 2018-04-25 02:22 PM, 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.
>
>
> I write programs on SoloLearn mobile app.
>
>
>
> Warm regards,
> Julia Kim
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



More information about the Python-ideas mailing list