Explanation "Count Substring Occurrences"
Hello, I'm a beginner, I don't understand this lines :
ind = res = 0 and while (ind:= mainstr.find(substr, ind))!= -1:
in this code : ind = res = 0 mainstr = mainstr.lower() substr = substr.lower() while (ind:= mainstr.find(substr, ind))!= -1: res += 1 ind += 1
return res
Why do you create res ? Is ind not enought ?