A heterogram is a word, phrase, or sentence in which no letter of the alphabet occurs more than once.
The terms isogram and nonpattern word have also been used to mean the same thing
Isogram has also been used to mean a string where each letter present is used the same number of times. Multiple terms have been used to describe words where each letter used appears a certain number of times.
For example, a word where every featured letter appears twice, like “appeases”, might be called a pair isogram, a second-order isogram, or a 2-isogram.
A perfect pangram is an example of a heterogram, with the added restriction that it uses all the letters of the alphabet.
Code Examples
def isogram_checker(word): # Convert to lower case clean_word = word.lower() # Make a list for unique letters letter_list = [] for letter in clean_word: if letter.isalpha(): if letter in letter_list: return False letter_list.append(letter) return True print(isogram_checker("test")) print(isogram_checker("python")) print(isogram_checker("maxpython.com"))
def is_isogram(string): # if not a Str then return False if type(string) is not str: return False # if empty then return True if len(string)==0: return True # store characters db = set() # loop through the string, but lowercase it first for char in string.lower(): # if it's already been seen, then return False if char in db: return False else: # otherwise add to the db db.append(char) # return True if not failed return True