You are viewing a single comment's thread. Return to all comments →
def count_substring(string, sub_string): substring_len = len(sub_string) counting = 0 for i in range(len(string)): if len(string)-i >= substring_len: joined_letter = "" for j in range(substring_len): joined_letter += string[i+j] if joined_letter == sub_string: counting += 1 else: break return counting if __name__ == '__main__': string = input().strip() sub_string = input().strip() count = count_substring(string, sub_string) print(count)
Seems like cookies are disabled on this browser, please enable them to open this website
Find a string
You are viewing a single comment's thread. Return to all comments →