Want to improve this question? Add details and开发者_运维技巧 clarify the problem by editing this post.
Closed 45 mins ago.
Improve this questiondirection = 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"))
def caesar(plain_text, shift_amount, direction_d):
cipher_text = ""
for letter in plain_text:
position = alphabet.index(letter)
if direction_d == "encode" :
new_position = position + shift_amount
cipher_text += alphabet[new_position]
print(f"The encoded text is {cipher_text}")
if direction == "decode":
new_position = position - shift_amount
cipher_text += alphabet[new_position]
print(f"The encoded text is {cipher_text}")
caesar(plain_text = text , shift_amount = shift, direction_d = direction)
I want to print last line of the first if statement but if I exit for loop (to do that) it will interrupt the second loop which i've already exited loop and I can print the last line of loop.
精彩评论