fork download
  1. import re
  2.  
  3. def remove_more_than_two_reps(text):
  4. return re.sub(r'(.)\1{2,}', r'\1\1', text)
  5.  
  6. text = 'teeeexxxxt'
  7.  
  8. print(remove_more_than_two_reps(text))
  9.  
Success #stdin #stdout 0.03s 9544KB
stdin
Standard input is empty
stdout
teexxt