Is there a command that returns the number of substrings in a string?
Erik Max Francis
max at alcyone.com
Fri Oct 23 23:22:38 EDT 2009
Peng Yu wrote:
> For example, the long string is 'abcabc' and the given string is
> 'abc', then 'abc' appears 2 times in 'abcabc'. Currently, I am calling
> 'find()' multiple times to figure out how many times a given string
> appears in a long string. I'm wondering if there is a function in
> python which can directly return this information.
The .count string method.
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
Diplomacy and defense are not substitutes for one another. Either
alone would fail. -- John F. Kennedy, 1917-1963
More information about the Python-list
mailing list