fork download
  1. def display_th_occurrences(text):
  2. # Find all occurrences of "th" in the text
  3. index = 0
  4. while index < len(text):
  5. index = text.find("th", index)
  6. if index == -1:
  7. break
  8. print("th")
  9. index += 2 # Move past the current occurrence
  10.  
  11. # Example usage
  12. text = "This is the path that leads to the cathedral."
  13. display_th_occurrences(text)
Success #stdin #stdout 0.03s 9724KB
stdin
Standard input is empty
stdout
th
th
th
th
th