Skip to main content

Posts

Showing posts from July, 2019

Find a string Hackerrank Python Solution

def count_substring(string,sub_string): c= 0 for n in range ( len (string), 0 , -1 ): try : if string[n- len (sub_string):n]==sub_string: c+= 1 except IndexError: break return c if __name__ == '__main__' : string = input ().strip() sub_string = input ().strip() count = count_substring(string, sub_string) print (count)