Articles → Python → Count String Function In PythonCount String Function In PythonIn this article, we will discuss count string function in python.Purpose Count function counts the number of occurrences of a given string in another string.Example Consider the following examplestr = "this is string example" print ("number of occurrences of letter 'e' are:", str.count('e'))Here I want to check the occurrence of character ‘e’ in the string. Here ‘e’ comes twice in the word ‘example’. Now run the above code and you will get following output.Click to EnlargePosted By - Karan Gupta Posted On - Wednesday, February 20, 2019 Query/Feedback Your Email Id Subject Query/Feedback Characters remaining 250
str = "this is string example" print ("number of occurrences of letter 'e' are:", str.count('e'))
Query/Feedback