We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- Find a string
- Discussions
Find a string
Find a string
Sort by
recency
|
3377 Discussions
|
Please Login in order to post a comment
def count_substring(string, sub): count = 0 longsub = len(sub) compare = "" concidence = 0 for i in string: count += 1 compare += i
return sum(string.startswith(sub_string,i) for i in range(len(string)-1))
if sub_string[0] == sub_string[len(sub_string) - 1]: x = string.count(f"{sub_string}") + 1 return x else: x = string.count(f"{sub_string}") return x