string.count issue (i'm stupid?)
Matteo Rattotti
matteo.rattotti at gmail.com
Mon May 22 06:59:15 EDT 2006
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...
Can someone explain me this? And in which way i can count all the
occurrence of a substring in a master string? (yes all occurrence
reusing already counter character if needed)
Thanks a lot
Matteo Rattotti www.rknet.it
Powered by:
- MacOsX
- Gnu / Linux Debian Sarge
- Amiga Os 3.9
- Milk
More information about the Python-list
mailing list