#19 : Find a String | Hackerrank Python Solutions

preview_player
Показать описание
Thanks if u r Watching us....
#Python #Dev19 #HackerankSolutions #C #C++ #Java #Python #C
Please Subscribe Us ....
Рекомендации по теме
Комментарии
Автор

def count_substring(string, sub_string):
count=0
for i in range(len(string)):
if
count=count+1

return count

if __name__ == '__main__':
string = input().strip()
sub_string = input().strip()

count = count_substring(string, sub_string)
print(count)

laxmikantadahal
Автор

For I in range(0, ml):
If substring==string[i:i+sl]:
C+=1

RajeshR-hmxr
Автор

I have a doubt dear admin.
String : Krishna
Substring : Kri
It is giving the output 1 but the output must be
can you explain this?

nunnasaicharan
Автор

why does it not throw arraylist out of bound exception and passes all test I am iterating to full string ?

count =0
fl = len(string)
sl = len(sub_string)
for i in range(fl):
if string[i:i+sl] == sub_string:
count +=1

return count

aishwary
Автор

why does this not work ? this fails two test cases out of all

def count_substring(string, sub_string):
count = string.count(sub_string)
return count

if __name__ == '__main__':
string = input().strip()
sub_string = input().strip()

count = count_substring(string, sub_string)
print(count)

aishwary
Автор

bhava explain thoda ajun detail madhe karat jaa na please if possible....baaki its very helpfull

anujpathak
Автор

Tell the solution using string in built function if any,

drishtijain
Автор

Did not really understand how it works

sushmamc
Автор

explanation not satisfactory, but good approach.

TJ-woxt