You are viewing a single comment's thread. Return to all comments →
hi guys this is my ans u can also use this to visualize better https://pythontutor.com/render.html#mode=display
1 string = "ABCDCDC" 2 sub_string = "CDC" 3 temp_str = "" 4 occ = 0 5 for i in range(len(string)-len(sub_string)+1): 6 temp_str = string[:len(sub_string)] 7 string = string[1:] 8 if sub_string == temp_str: 9 occ += 1 10 print(occ)
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 →
hi guys this is my ans u can also use this to visualize better https://pythontutor.com/render.html#mode=display