def main():
print("Введите слово для шифровки")
text = input()
print("Введите ключ")
key = int(input())
alphabet = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
encrypted = ""
for i in text:
if i in alphabet:
encrypted += alphabet[(alphabet.index(i)+key)%26]
else:
encrypted += i
print(encrypted)
def main2():
print("Введите слово для расшифровки")
decrypted = ""
decrypted += alphabet[(alphabet.index(i)-key)%26]
decrypted += i
print(decrypted)
if __name__ == "__main__":
main()
main2()
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
def main():
print("Введите слово для шифровки")
text = input()
print("Введите ключ")
key = int(input())
alphabet = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
encrypted = ""
for i in text:
if i in alphabet:
encrypted += alphabet[(alphabet.index(i)+key)%26]
else:
encrypted += i
print(encrypted)
def main2():
print("Введите слово для расшифровки")
text = input()
print("Введите ключ")
key = int(input())
alphabet = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
decrypted = ""
for i in text:
if i in alphabet:
decrypted += alphabet[(alphabet.index(i)-key)%26]
else:
decrypted += i
print(decrypted)
if __name__ == "__main__":
main()
main2()