aboutsummaryrefslogtreecommitdiff
path: root/challenge-207/roger-bell-west/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-207/roger-bell-west/python/ch-1.py')
-rwxr-xr-xchallenge-207/roger-bell-west/python/ch-1.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-207/roger-bell-west/python/ch-1.py b/challenge-207/roger-bell-west/python/ch-1.py
new file mode 100755
index 0000000000..2742cbdd6f
--- /dev/null
+++ b/challenge-207/roger-bell-west/python/ch-1.py
@@ -0,0 +1,19 @@
+#! /usr/bin/python3
+
+import re
+
+def keyboardword(wl):
+ rl = re.compile(r"^([qwertyuiop]+|[asdfghjkl]+|[zxcvbnm]+)$", re.IGNORECASE)
+ return [w for w in wl if re.match(rl, w)]
+
+import unittest
+
+class TestKeyboardword(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(keyboardword(["Hello", "Alaska", "Dad", "Peace"]), ["Alaska", "Dad"], 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(keyboardword(["OMG", "Bye"]), [], 'example 2')
+
+unittest.main()