1660. Thousand Separator
My accepted Python solution to LeetCode problem 1660, Thousand Separator, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.4MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.4MB, accepted 2025-12-30.
class Solution:
def thousandSeparator(self, n: int) -> str:
s = str(n)
result = []
for i, c in enumerate(reversed(s)):
if i > 0 and i % 3 == 0:
result.append('.')
result.append(c)
return ''.join(reversed(result))