Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

return the count of a given substring from a string python

str_x = "He is a good programmer. He Is good. He is he he he he he " 

count1 = str_x.count("He") # Counts the word "He" in the string. Remember, case sensitive!
count2 = str_x.count("he") #Counts the word "he" in the string. Remember, case sensitive!

print(count1 + count2) # Shows the total count of the word "He" in console
 
PREVIOUS NEXT
Tagged: #return #count #substring #string #python
ADD COMMENT
Topic
Name
1+4 =