Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions solutions/python/isogram/2/isogram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Isogram.

Determine if a word or phrase is an isogram.

An isogram (also known as a "non-pattern word") is a word or phrase
without a repeating letter, however spaces and hyphens are allowed
to appear multiple times.

Examples of isograms:

lumberjacks
background
downstream
six-year-old

The word isograms, however, is not an isogram, because the s repeats.
"""


def is_isogram(string: str) -> bool:
"""
Determine if a word or phrase is an isogram.

An isogram is a word or phrase without repeating letters. Spaces and hyphens
are allowed to appear multiple times, but alphabetic characters must be unique
(case-insensitive).

:param string: The word or phrase to check
:type string: str
:returns: True if the string is an isogram, False otherwise
:rtype: bool
"""
letters: list[str] = [char for char in string.lower() if char.isalpha()]
return len(letters) == set(letters)
Loading