Skip to content

Commit 6327ad2

Browse files
committed
Code for isogram in python.
1 parent cf145f7 commit 6327ad2

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

exercises/isogram/example.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def isogram(string):
2+
string = string.lower()
3+
return len(set(string)) == len(string)
4+

exercises/isogram/isogram_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import unittest
2+
from example import isogram
3+
4+
5+
class TestIsogram(unittest.TestCase):
6+
7+
def test_isogram(self):
8+
tests = ['lumberjacks', 'background', 'downstream']
9+
for test in tests:
10+
string = isogram(test)
11+
self.assertTrue(string, True)
12+
13+
def test_isogram_false(self):
14+
tests = ['isograms', 'aba', ' ']
15+
for test in tests:
16+
string = isogram(test)
17+
self.assertFalse(string, False)
18+
19+
if __name__ == '__main__':
20+
unittest.main()

0 commit comments

Comments
 (0)