“Policz podłoże w Python String” Kod odpowiedzi

Python Substring Count

def count_substring(string, sub_string):
    c = 0
    while sub_string in string:
        c += 1           
        string = string[string.find(sub_string)+1:]
    return c
adityapapu

Jak liczyć podłoże w ciągu w Pythonie

count = string.count(substring)
Brave Buffalo

Policz podłoże w Python String

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  
Repulsive Ratel

Odpowiedzi podobne do “Policz podłoże w Python String”

Pytania podobne do “Policz podłoże w Python String”

Więcej pokrewnych odpowiedzi na “Policz podłoże w Python String” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu