Ctrl K

Bracket the Dots

Easy
To keep an IP address in an email from turning into a clickable link, people "defuse" it by replacing every dot . with [.]. Given a valid IPv4 address ip, return its defused form.
Example 1
ip='10.0.0.1' → '10[.]0[.]0[.]1'

Each of the three dots becomes [.].

Example 2
ip='172.16.254.3' → '172[.]16[.]254[.]3'

The digits stay as they are; only the dots change.

Constraints
  • ip is a valid IPv4 address: four numbers from 0 to 255 separated by dots, with no leading zeros
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
ip='10.0.0.1'
Expected
'10[.]0[.]0[.]1'

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