def special_format(n): s, *d = str(n).partition(".") r = ",".join([s[x-2:x] for x in range(-3, -len(s), -2)][::-1] + [s[-3:]]) return "".join([r] + d) print(special_format(1)) print(special_format(12)) print(special_format(123)) print(special_format(1234)) print(special_format(12345)) print(special_format(123456)) print(special_format(12345678901234567890)) print(special_format(1.0)) print(special_format(12.34)) print(special_format(1234567890.1234567890))
Standard input is empty