Matteo Rattotti wrote: > Hi all, > > i've noticed a strange beaviour of string.count: > > in my mind this code must work in this way: > > str = "a_a_a_a_" > howmuch = str.count("_a_") > print howmuch -> 3 > > but the count return only 2 > > Ok this can be fine, but why? The doc string tell that count will > return the number of substring in the master string, if we spoke about > substring i count 3 substring...
It appears to be a documentation bug. It should say something about non-overlapping occurences. Better would be of course to introduce a parameter that defines the behavior, either overlapping or not. Diez -- http://mail.python.org/mailman/listinfo/python-list