1alphabet = ['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']
2
3def caesar(start_text, shift_amount, cipher_direction):
4 end_text = ""
5 if cipher_direction == "decode":
6 shift_amount *= -1
7 for char in start_text:
8 if char in alphabet:
9 position = alphabet.index(char)
10 new_position = position + shift_amount
11 end_text += alphabet[new_position]
12 else:
13 end_text += char
14 print(f"Here's the {cipher_direction}d result: {end_text}")
15
16
17should_end = False
18while not should_end:
19
20 direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
21 text = input("Type your message:\n").lower()
22 shift = int(input("Type the shift number:\n"))
23 shift = shift % 26
24
25 caesar(start_text=text, shift_amount=shift, cipher_direction=direction)
26
27 restart = input("Type 'yes' if you want to go again. Otherwise type 'no'.\n")
28 if restart == "no":
29 should_end = True
30 print("Thanks for using me")
31
1#novince coder, dont know if im doing this right XD
2EncodingValues = ['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B',',','N','M','!','@','$','%','^','&','*','(',')','_','+','-','=','#']
3encode = "this"
4
5def encode(string):
6 encodedcode = ""
7 LetterToEncode = 0
8 for i in string:
9 LetterToEncode = LetterToEncode + 1
10 encodedcode = encodedcode + EncodingValues.index(LetterToEncode)
11 encodedcode = encodedcode + " "
12 #still editing this
13
14def decode(string):
15 decodedcode = ""
16 LetterToDecode = 0
17 for i in string:
18 LetterToDecode = LetterTodecode + 1
19 if string.index(letterToDecode + 2) = " "
20 decodedcode = decodedcode + EncodingValues.index(LetterToDecode)