Leetcode 1660 Solution

This article provides solution to leetcode question 1660 (thousand-separator)

https://leetcode.com/problems/thousand-separator

Solution

class Solution: def thousandSeparator(self, n: int) -> str: ans = "" str_n = str(n)
for i, ch in enumerate(str_n): if (len(str_n) - i) % 3 == 0 and i != 0: ans += '.' ans += ch
return ans