반응형
logo = """
,adPPYba, ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYYba, 8b,dPPYba,
a8" "" "" `Y8 a8P_____88 I8[ "" "" `Y8 88P' "Y8
8b ,adPPPPP88 8PP""""""" `"Y8ba, ,adPPPPP88 88
"8a, ,aa 88, ,88 "8b, ,aa aa ]8I 88, ,88 88
`"Ybbd8"' `"8bbdP"Y8 `"Ybbd8"' `"YbbdP"' `"8bbdP"Y8 88
88 88
"" 88
88
,adPPYba, 88 8b,dPPYba, 88,dPPYba, ,adPPYba, 8b,dPPYba,
a8" "" 88 88P' "8a 88P' "8a a8P_____88 88P' "Y8
8b 88 88 d8 88 88 8PP""""""" 88
"8a, ,aa 88 88b, ,a8" 88 88 "8b, ,aa 88
`"Ybbd8"' 88 88`YbbdP"' 88 88 `"Ybbd8"' 88
88
88
"""
import art
print(art.logo)
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','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 caesar(text, shift, direction):
end_text = ""
if direction == "decode":
shift *= -1
for char in text:
if char in alphabet:
position = alphabet.index(char)
new_position = position + shift
end_text += alphabet[new_position]
else:
end_text += char
print(f"{direction} : {end_text}")
flag = True
while flag:
direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))
shift = shift % 26
caesar(text, shift, direction)
result = input("type 'yes' or 'no' : ").lower()
if result == "no":
flag = False
print("goodbye")
반응형
'파이썬 > exercise' 카테고리의 다른 글
9-2. python dictionary in list (0) | 2023.01.04 |
---|---|
9-1. python dictionary 성적 등급 매기는 프로그램 (0) | 2023.01.04 |
8-2. python prime number checker (0) | 2023.01.04 |
8-1. python function - math ceil (0) | 2023.01.04 |
7. python hangmangame (0) | 2023.01.04 |