import re s = 'h.e.ll.o w.o.r.l.d'print(re.sub(r'\w+(?:\.+\w+)*', lambda x: x.group(0).replace('.', ''), s))
Standard input is empty
hello world
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!