Так что в данный момент я застрял в этой части задачи: если команда decode , то программа должна запросить строку для декодирования и текстовое слово, которое появляется в тексте ( расшифрованная строка). Выходными данными должно быть вращение, необходимое для декодирования строки и декодированной строки (текста).
Если программа получает одно слово, которое принадлежит декодированной строке, то программа ищет вращение, которое находит это слово в декодированной строке. Это правильное вращение. Обнаружение этой ротации является целью программы.
Если вращение не найдено, программа должна указать этот факт.
#User Greeting
greeting = print("Hello! Welcome to the Caesar Cipher!")
#List Command Options
prompt1 = input("Select a commend: \n'e' to encode,\n'd' to decode, or\n'q' to quit\n")
while prompt1 not in ["e", "d", "q"]:
print("Invalid choice")
prompt1 = input("Select a commend: \n'e' to encode,\n'd' to decode, or\n'q' to quit\n")
#Encode Option
if prompt1 == "e":
prompt2 = input("Please enter a lowercase word string to encode: ")
c = 0
for c in prompt2:
if not c.isalpha():
print("Letters only please!")
prompt2 = input("Please enter a lowercase word string to encode: ")
elif c.isupper():
print("No uppercase please!")
prompt2 = input("Please enter a lowercase word string to encode: ")
prompt3 = int(input("Please enter a rotation number between 1-25: "))
if prompt3 not in range(1,25):
print("Out of range")
prompt3 = input("Please enter a rotation number between 1-25: ")
output = ""
alphabet = "abcdefghijklmnopqrstuvwxyz"
for c in prompt2:
if c in alphabet:
output += alphabet[(alphabet.index(c)+prompt3)%(len(alphabet))]
print("Your cipher is: " + output)
#Decode Option
if prompt1 == "d":
prompt4 = input("Please enter a lowercase word string to decode: ")
c = 0
for c in prompt4:
if not c.isalpha():
print("Letters only please!")
prompt4 = input("Please enter a lowercase word string to decode: ")
elif c.isupper():
print("No uppercase please!")
prompt4 = input("Please enter a lowercase word string to decode: ")
prompt5 = input("Please enter a lowercase word in the decoded string: ")
for c in prompt5:
if not c.isalpha():
print("Letters only please!")
prompt5 = input("Please enter a lowercase word in the decoded string: ")
elif c.isupper():
print("No uppercase please!")
prompt5 = input("Please enter a lowercase word in the decoded string: ")
numberoutput = ""
list(prompt4)
print("Your rotation number is: " + numberoutput)
#Quit Option
if prompt1 == "q":
print("Goodbye! Come back soon!")