import itertools def all_combinations(alphabet, max_length): """Генерирует все комбинации длиной от 1 до max_length""" all_combos = [] for length in range(1, max_length + 1): combos = itertools.product(alphabet, repeat=length) all_combos.extend([''.join(combo) for combo in combos]) return all_combos russian_lower = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя' def vectorize(word, combinations): vector = [] if len(word) == 1: return None last = None for curr in word: if not last: last = curr continue pair = last + curr indx = combinations.index(pair) vector.append(indx) return vector word = 'маме' combinations = all_combinations(russian_lower, 2) result = vectorize(word, combinations) print("Все комбинации длиной 1-2:") print(combinations) print("Вектор:", result)