Searching strings for a substring : String count : String PYTHON examples


PYTHON examples » String » String count »

 

Searching strings for a substring


Searching strings for a substring: counting the occurrences of a substring


string1 = "Test1, test2, test3, test4, Test5, test6"

print '"test" occurs %d times in nt%s' % ( string1.count( "test" ), string1 )
print '"test" occurs %d times after 18th character in nt%s' % 
   ( string1.count( "test", 18, len( string1 ) ), string1 )
print
           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo String
» String count