count()

my_str.count(search_string,start,end))
search_string : String to be searched for matching inside main string.
start: Optional , search can be started from this position
end : Optional , search can be ended from this position.
my_str="Welcome to plus2net.com"
print(my_str.count('co'))      # Output is 2
print(my_str.count('co',4))    # Output is 1 
print(my_str.count('co',4,18)) # Output is 0
Using a list
my_list=['one','two','three']
print(my_list.count('two'))      # Output is 1


All String methods



plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer