fork download
  1. string = 'abcdcdc'
  2. sub_string = 'cdc'
  3.  
  4. count = 0
  5. for i in range(len(string)):
  6. if string[i:i+len(sub_string)] == sub_string:
  7. count += 1
  8.  
  9. print(count)
Success #stdin #stdout 0.03s 28376KB
stdin
Standard input is empty
stdout
2