import re for s in [ "2121212121", "1188511885", "38593859" ]: print(re.sub(r'(.+?)\1+', r'\1', s))
Standard input is empty
21 185185 3859
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!