How can I count the number of times a given substring is present within a string in Python?
For example:
>>> \'foo bar foo\'.numberOfOccurre
string="abc" mainstr="ncnabckjdjkabcxcxccccxcxcabc" count=0 for i in range(0,len(mainstr)): k=0 while(k