Leetcode 1660 Solution
This article provides solution to leetcode question 1660 (thousand-separator)
Access this page by simply typing in "lcs 1660" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
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