aboutsummaryrefslogtreecommitdiff
path: root/challenge-287/zapwai/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-287/zapwai/python/ch-2.py')
-rw-r--r--challenge-287/zapwai/python/ch-2.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-287/zapwai/python/ch-2.py b/challenge-287/zapwai/python/ch-2.py
new file mode 100644
index 0000000000..867df4f639
--- /dev/null
+++ b/challenge-287/zapwai/python/ch-2.py
@@ -0,0 +1,35 @@
+import re
+def proc(mystr) :
+ print("Input:", mystr)
+ output = "False"
+ p = mystr.split(".")
+ if len(p) == 1 :
+ if re.search('^\d+$', mystr):
+ output = "True"
+ elif re.search('^\d+e\d+$|^\d+E\d+$', mystr):
+ output = "True"
+ elif len(p) == 2:
+ if re.search('^\d+$', p[0]) and re.search('^\d+$', p[1]):
+ output = "True"
+ elif re.search('^\d+$', p[0]) and re.search('^\d+e\d+$|^\d+E\d+$', p[1]):
+ output = "True"
+
+ print("Output:", output)
+
+mystr = "1"
+proc(mystr)
+mystr = "56e10"
+proc(mystr)
+mystr = "2E32"
+proc(mystr)
+mystr = "a"
+proc(mystr)
+mystr = "1.2"
+proc(mystr)
+mystr = "1.2.6"
+proc(mystr)
+mystr = "3.142e10"
+proc(mystr)
+mystr = "3.142e42B"
+proc(mystr)
+