Ctrl K

Dotted Thousands

Easy
You are given a non-negative integer n. Write its decimal form as a string, splitting the digits into groups of three from right to left and putting a dot . between the groups. The leftmost group may have one, two or three digits. Return the resulting string.
Example 1
n=45067 → '45.067'

The last three digits 067 are split off, leaving 45 in front: "45.067".

Example 2
n=812 → '812'

The number has only three digits, so no separator is needed.

Example 3
n=3000000 → '3.000.000'

Two full groups of zeros are split off with dots: "3.000.000".

Constraints
  • 0 ≤ n ≤ 2³¹ − 1
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
n=45067
Expected
'45.067'

Run checks the first 3 tests in your browser. Submit checks all 34 tests on the server, hidden ones included.