Answers for "how to use count function in python"

0

count function in python

>>> sentence = 'Mary had a little lamb'
>>> sentence.count('a')
4
Posted by: Guest on February-06-2022
-2

count substring in string python

def count_substring(string,sub_string):
    l=len(sub_string)
    count=0
    for i in range(len(string)-len(sub_string)+1):
        if(string[i:i+len(sub_string)] == sub_string ):      
            count+=1
    return count
Posted by: Guest on October-14-2020
-2

what is the use of count function in python

count = 0 
while count < 10 :
  print("Hello")
  count += 1
Posted by: Guest on March-02-2021

Code answers related to "how to use count function in python"

Python Answers by Framework

Browse Popular Code Answers by Language