aboutsummaryrefslogtreecommitdiff
path: root/challenge-272/sgreen/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-272/sgreen/python/ch-1.py')
-rwxr-xr-xchallenge-272/sgreen/python/ch-1.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-272/sgreen/python/ch-1.py b/challenge-272/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..9e72a22790
--- /dev/null
+++ b/challenge-272/sgreen/python/ch-1.py
@@ -0,0 +1,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()