1. What I learned

    a. replace() method

        When I want to replace one with another in a string, I can use replace() method.
        ex) sample.replace(“from”, “to”)
        cf) I can use either ‘ ‘ or “ “

    b. join() method

        This method divides the sample into “from” and combines it into “to” instead of “from”.
        ex) “to”.join(sample.split(“from”))
        cf) I can use either ‘ ‘ or “ “

2. How I sloved

    All I have to do is replacing “.” with “[.]”. So there are two ways. One is to replace, the other is to divide into “.”, and then combines everything by adding “[.]”.

3. Code

class Solution:  
    def defangIPaddr(self, address: str) -> str:  
        return address.replace(".","[.]")  

class Solution:  
    def defangIPaddr(self, address: str) -> str:  
        return "[.]".join(address.split('.'))  

4. Result

        Runtime : 16 ms(99.51%), Memory usage : 12.7 MB(100.00%)
        (Runtime can be different by a system even if it is a same code.)

Check out the my GitHub repo for more info on the code. If you have questions, you can leave a reply on this post.