Join us Create a HackerRank account Be part of a 26 million-strong community of developers Please signup or login in order to view this challenge I agree to HackerRank's Terms of Service and Privacy Policy. Sign up or Continue with Google LinkedIn GitHub Facebook Already have an account?Log in
defcount_substring(string,sub_string):count=0;foriinrange(len(sub_string),len(string)+1):if(string[i-len(sub_string):i]==sub_string):count+=1returncount count_substring():=0foriinrange(0,len(string)):if(string[i:i+len(sub_string)]==sub_string):count+=1print(count)s=input()s...
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=0sub_len=len(sub_string)foriinrange(0,len(string)):ifstring[i]==sub_stri...
Being said that, its matter of personal preference and you could use any valid special character or use conventional alphabets instead. I hope this clarifies use of underscore. string[_:_
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....