Home >>Python String Methods >Python String count() Method
Python string count() method is used to return the number of times a particular value appears in the given input string.
Syntax:string.count(value, start, end)
Parameter | Description |
---|---|
value | This is a required parameter. It defines the string to value to search for. |
start | This is an optional parameter. It defines the position to start the search. |
end | This is an optional parameter. It defines the position to end the search. |
txt = "Here at PHPTPOINT we learn PHP and also work on the PHP projects"
x = txt.count("PHP")
print(x)
txt = "Here at PHPTPOINT we learn PHP and also work on the PHP projects"
x = txt.count("PHP", 10, 34)
print(x)