- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
import re
alphabet = ['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']
text = input('Enter your message: ')
text = re.findall(r'\w', text)
key = input('Enter your key: ')
key = int(key)
a = len(text)
b = 0
num = 0
message = []
c = ''
for i in range(a):
num = alphabet.index(text[b])
num = num + key
b = b + 1
if num <= 25:
message.append(alphabet[num])
else:
num = num%25 - 1
message.append(alphabet[num])
print(text)
print(message)
for i in range(a):
c += message[(i)]
print(c)
Комментарии (0) RSS
Добавить комментарий