← pynet

exercise 3

626fb15bd2868bc9902b80f142ef4cb4f39da7c1 · ovidiucs · Sep 9, 2015 12:09

+14 · 1 file changed

  • exercise_3.py +14 −0
diff --git a/exercise_3.py b/exercise_3.py
new file mode 100755
index 0000000..8a977a8
--- /dev/null
+++ b/exercise_3.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python2
+
+'''
+Here is an example using this script where I echo an IP address into it and then
+the IP address is split into its octets.
+
+$ echo '192.168.1.1'  | ./test3.py 
+['192', '168', '1', '1\n']
+'''
+
+import fileinput
+
+for line in fileinput.input():
+        print line.rstrip().split('.')