File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
solutions/python/isogram/3 Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Isogram.
3+
4+ Determine if a word or phrase is an isogram.
5+
6+ An isogram (also known as a "non-pattern word") is a word or phrase
7+ without a repeating letter, however spaces and hyphens are allowed
8+ to appear multiple times.
9+
10+ Examples of isograms:
11+
12+ lumberjacks
13+ background
14+ downstream
15+ six-year-old
16+
17+ The word isograms, however, is not an isogram, because the s repeats.
18+ """
19+
20+
21+ def is_isogram (string : str ) -> bool :
22+ """
23+ Determine if a word or phrase is an isogram.
24+
25+ An isogram is a word or phrase without repeating letters. Spaces and hyphens
26+ are allowed to appear multiple times, but alphabetic characters must be unique
27+ (case-insensitive).
28+
29+ :param string: The word or phrase to check
30+ :type string: str
31+ :returns: True if the string is an isogram, False otherwise
32+ :rtype: bool
33+ """
34+ # empty string
35+ if not string :
36+ return True
37+
38+ letters : list [str ] = [char for char in string .lower () if char .isalpha ()]
39+ return len (letters ) == len (set (letters ))
You can’t perform that action at this time.
0 commit comments