Here is a code I wrote to check for the number of occurrence of a sub_string within a string:
a = 'ABCDCD' #Main String
b = 'CDC'    #Sub String
sub_Len = len(b)
occurrence = 0
for s in range(len(a)):
    if a[s:s+sub_Len] == b:
        occurrence += 1 
 
     
     
    