MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / is_isogram

Function is_isogram

strings/is_isogram.py:6–23  ·  view source on GitHub ↗

An isogram is a word in which no letter is repeated. Examples of isograms are uncopyrightable and ambidextrously. >>> is_isogram('Uncopyrightable') True >>> is_isogram('allowance') False >>> is_isogram('copy1') Traceback (most recent call last): ... ValueErr

(string: str)

Source from the content-addressed store, hash-verified

4
5
6def is_isogram(string: str) -> bool:
7 """
8 An isogram is a word in which no letter is repeated.
9 Examples of isograms are uncopyrightable and ambidextrously.
10 >>> is_isogram('Uncopyrightable')
11 True
12 >>> is_isogram('allowance')
13 False
14 >>> is_isogram('copy1')
15 Traceback (most recent call last):
16 ...
17 ValueError: String must only contain alphabetic characters.
18 """
19 if not all(x.isalpha() for x in string):
20 raise ValueError("String must only contain alphabetic characters.")
21
22 letters = sorted(string.lower())
23 return len(letters) == len(set(letters))
24
25
26if __name__ == "__main__":

Callers 1

is_isogram.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected