Skip to content

Commit 4be3429

Browse files
committed
Code for isogram in python.
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter. Examples of isograms: -lumberjacks -background -downstream The word isograms, however, is not an isogram, because the s repeats. Signed-off-by: Satyajit Bulage <[email protected]>
1 parent cf145f7 commit 4be3429

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

exercises/isogram/example.py

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

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)