num = 10000 // Your number str_num = str(num) output = '' count = 1 for i in str_num[::-1]: if count % 3 == 0: output = output + i + '.' count = 0 else: output = output + i count += 1 return output[::-1]