From 3e3e9530a265cb3f549a3556bb78ffdcb1023650 Mon Sep 17 00:00:00 2001 From: David Ferrone Date: Mon, 16 Sep 2024 12:02:14 -0400 Subject: Week 287 --- challenge-287/zapwai/python/ch-2.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 challenge-287/zapwai/python/ch-2.py (limited to 'challenge-287/zapwai/python/ch-2.py') 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) + -- cgit