Krypto_Grundlagen/utils/AlphabetUtils.py

17 lines
450 B
Python
Raw Normal View History

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 get_letter_at_index(idx: int, capital: bool = False):
if idx < 0 or idx > 25:
raise AttributeError
return LETTERS[idx] if capital else LETTERS[idx].lower()
def get_index_of_letter(letter: str):
if letter.upper() not in LETTERS:
raise AttributeError
return LETTERS.index(letter.upper())