Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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']
- direction = input("Type 'encode' to encrypt, type 'decode' to decrypt: ").lower()
- text = input("Type your message: ").lower()
- shift = int(input("Type the shift number:"))
- def caesar(direction_, text_, shift_):
- end_text = ""
- if direction == "decode":
- shift_ *= -1
- for letter in text_:
- position = alphabet.index(letter)
- new_position = position + shift_
- end_text += alphabet[new_position]
- print(f"The {direction}d text is {end_text}")
- caesar(direction, text, shift)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement