aboutsummaryrefslogtreecommitdiff
path: root/challenge-272/sgreen/python/ch-1.py
blob: 9e72a22790666c2a773e493c5b77182949d54913 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3

import sys


def defang_ip(ip: str) -> str:
    """
    Replaces all occurrences of '.' in the given IP address with '[.]'.

    Args:
        ip (str): The IP address to defang.

    Returns:
        str: The defanged IP address.

    """
    return ip.replace('.', '[.]')


def main():
    result = defang_ip(sys.argv[1])
    print(result)


if __name__ == '__main__':
    main()