For a hackerrank challenge to print the number of times that the substring occurs in the given string, I wrote attached logic. But I keep receiving 0 has output. Please share comments on the logic where missing.
To print the number of times that the substring occurs in the given string
def count_substring(string, sub_string):
count = 0
for i in range(0,len(string)):
if(sub_string== string[i:i+len(sub_string)]):
count= ++count
return count
if __name__ == '__main__':
string = input().strip()
sub_string = input().strip()
count = count_substring(string, sub_string)
print(count)
Input for string and sub_string is ABCDCDC,CDC
Expected output is 2, but the actual Result 0