aboutsummaryrefslogtreecommitdiff
path: root/challenge-135/abigail/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-135/abigail/python/ch-1.py')
-rw-r--r--challenge-135/abigail/python/ch-1.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-135/abigail/python/ch-1.py b/challenge-135/abigail/python/ch-1.py
new file mode 100644
index 0000000000..451fa94c9f
--- /dev/null
+++ b/challenge-135/abigail/python/ch-1.py
@@ -0,0 +1,24 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+import re
+
+for line in fileinput . input ():
+ line = re . sub (r'^[-+]', '', line . strip ())
+ ll = len (line)
+ if re . search (r'[^0-9]', line):
+ print ("not an integer")
+ elif ll % 2 == 0:
+ print ("even number of digits")
+ elif ll < 3:
+ print ("too short")
+ else:
+ print (line [(ll - 3) // 2 : (ll + 3) // 2])