from typing import List alphabet = ([ "А", "Б", "В", "Г", "Ґ", "Д", "Е", "Є", "Ж", "З", "И", "І", "Ї", "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ч", "Ш", "Щ", "Ь", "Ю", "Я" ]) from typing import List class EncryptedWord: def __init__(self, wordshifr): if isinstance(wordshifr, List): self.word =None self.shifr = wordshifr elif isinstance(wordshifr, str): self.shifr = None self.word = wordshifr else: raise TypeError("Input must be a list of integers or a string") if self.shifr is None: self.shifr = self.secret_shifr(self.word) elif self.word is None: self.word = self.decrypt() def decrypt(self) -> str: if self.shifr is None: raise ValueError("Encrypted word not set") return self.rsecret_shifr(self.shifr) def secret_shifr(self, word: str) -> List[int]: if not isinstance(word, str): raise TypeError("Word must be a string") word = word.upper() numbers = [] for i in word: numbers.append(alphabet.index(i) + 1) return numbers def rsecret_shifr(self, word: List[int]) -> str: if not isinstance(word, list): raise TypeError("Shifr must be a list of integers") letters = [] for i in word: letters.append(alphabet[i - 1]) return ("".join(letters)).title() a=EncryptedWord("") b=EncryptedWord("") print() print() # print(encrypted_word.shifr) # # print(encrypted_word.word) # print(encrypted_word.shifr) # print(encrypted_word.decrypt())