defcount_substring(string,sub_string):count=0foriinrange(len(string)-len(sub_string)+1):if(string[i:i+len(sub_string)]==sub_string):count+=1returncount like mine defcount_substring(string,sub_string):counter=0su
1if__name__=='__main__':2n =int(input())3arr =map(int, input().split())4print(sorted(list(set(arr)))[-2])
You are viewing a single comment's thread. Return to all comments → yashpalsinghdeo1 4 years ago here is problem solution in python 2 and python 3 programming. https://programs.programmingoneonone.com/2021/01/hackerrank-find-a-string-solution-python.html -8|ParentPermalink tamylv_pb 4 yea...
Find a string defcount_substring(string,sub_string):list_string=[]dup_string=string[:]foriinrange(1,len(string)):iflen(dup_string)>=len(sub_string):chars=dup_string[-len(sub_string):]list_string.append(chars)dup_string=dup_string[:-1]return(list_string.count(sub_string))...
here is the solution of problem f**ind a string** https://solution.programmingoneonone.com/2020/06/hackerrank-find-string-problem-solution-python.html -1|ParentPermalink manoharkharvi051 5 years ago count = 0 for i in range(0,len(string)-len(sub_string)+2): if (string[i:i+len(sub...
defcount_substring(string,sub_string):count=0ls,lss=len(string),len(sub_string)foriinrange(0,ls-lss+1):ifstring[i:i+lss]==sub_string:count+=1returncount
Find a string It's an old practice to use underscore for unused index/iterator variable so that variables like i or j which are commonly used for indexing purposes are not eaten up unnecessarily. Moreover, it gives hint that if index variable is underscore, then its not used in the ...
Find a string Writing one line but hard to undestand code is not considered a good programming practice.You will grasp when you gradually become mastered in Python.However I think writing this type of things only for fun is most suitable....