Safe IP Text
IP addresses are sometimes “defanged” in text so they do not turn into clickable links. Given a string address containing a valid IPv4 address, return the same address with every dot replaced by [.].
Примеры
Ввод
"1.1.1.1"Вывод
"1[.]1[.]1[.]1"Ввод
"255.100.50.0"Вывод
"255[.]100[.]50[.]0"Ввод
"0.0.0.0"Вывод
"0[.]0[.]0[.]0"Нужно реализовать
def defang_ip_addr(address: str) -> str:
Теги
strings
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
"1.1.1.1"Expected
"1[.]1[.]1[.]1"2
Input
"255.100.50.0"Expected
"255[.]100[.]50[.]0"3
Input
"0.0.0.0"Expected
"0[.]0[.]0[.]0"4
Input
"192.168.1.1"Expected
"192[.]168[.]1[.]1"5
Input
"8.8.8.8"Expected
"8[.]8[.]8[.]8"6
Input
"a"Expected
"a"Focus radio
Paused · SomaFM · Fluid