Python string count method
Count string in a string
We can use count method to find out the number of occurrences of a substring. count method has the following syntax.
s.count(sub [, start [, end]])
It counts the number of nonoverlapping
occurrences of sub in s, from offsets start to end (defaults: 0, len(s)
).
string1 = "Test1, test2, test3, test4, Test5, test6"
print string1.count( "test" )
print "test occurs after 18th character"
print string1.count( "test", 18, len( string1 ) )