fork download
  1. string = 'abcdcdc'
  2. sub_string = 'cdc'
  3.  
  4. start = count = 0
  5. while True:
  6. index = string.find(sub_string, start)
  7. if index >= 0:
  8. start = index + 1
  9. count += 1
  10. else:
  11. break
  12.  
  13. print(count)
Success #stdin #stdout 0.02s 28376KB
stdin
Standard input is empty
stdout
2