Give you an effective IPv4 Address address, Go back to this IP Invalid version of address .
The so-called invalidation IP Address , In fact, it is to use “[.]” Instead of every “.”.
Input :address = “1.1.1.1”
Output :“1[.]1[.]1[.]1”
Input :address = “255.100.50.0”
Output :“255[.]100[.]50[.]0”
class Solution:
def defangIPaddr(self, address: str) -> str:
ans = ''
for i in address:
if i == '.':
ans += '[.]'
else:
ans += i
return ans