LETTERS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] def is_letter_of_alphabet(letter: str): """ Checks if the given letter is a valid letter of the alphabet :param letter: The letter to check :return: If the letter is in the alphabet """ return letter.upper() in LETTERS def get_letter_at_index(idx: int, capital: bool = False): """ Returns the letter at the given index :param idx: The index of the letter to return :param capital: If the capitalized letter should be returned :return: The letter """ if idx < 0 or idx > 25: raise AttributeError return LETTERS[idx] if capital else LETTERS[idx].lower() def get_index_of_letter(letter: str): """ Returns the index of the given letter :param letter: The letter to return the index of :return: The index of the letter """ if letter.upper() not in LETTERS: raise AttributeError return LETTERS.index(letter.upper())