fixing the code
ALPHABET = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alphabet = ' abcdefghijklmnopqrstuvwxyz'
number = ' 12345678910'
key = 5
#i want c to be checked if it is upper later then deciphered as upper later but if it is lower then it desiphered as lower and if it is number it desiphered as number
def caesar_encrypt(plain_text):
cipher_text = ''
plain_text = plain_text.upper()
for c in plain_text:
index = ALPHABET.find(c)
index = (index+key)%len(ALPHABET)
cipher_text = cipher_text + ALPHABET[index]
return cipher_text
plain_text = plain_text.lower()
for c in plain_text:
index = alphabet.find(c)
index = (index+key)%len(alphabet)
cipher_text = cipher_text + alphabet[index]
return cipher_text
def caesar_decrypt(cipher_text):
plain_text = ''
for c in cipher_text:
index = ALPHABET.find(c)
index = (index-key)%len(ALPHABET)
plain_text = plain_text + ALPHABET[index]
for c in cipher_text:
index = alphabet.find(c)
index = (index-key)%len(alphabet)
plain_text = plain_text + alphabet[index]
return plain_text
if name=="main":
encrypted = caesar_encrypt('This is AN Example')
print(encrypted)
decrypted = caesar_decrypt(encrypted)
print(decrypted)
Is this a question?
yes i do not know how to connect these codes together to make the
sentence run prob @MrVoo
i want c to be checked if it is upper later then deciphered as upper later but if it is lower then it desiphered as lower and if it is number it desiphered as number this is what i want the code to do @MrVoo
@AhmadHamad3 Attach the repl, I can't run code by looking at it.
https://replit.com/@AhmadHamad3/alfa-desifer#main.py
@MrVoo
https://replit.com/@AhmadHamad3/alfa-desifer#main.py
@MrVoo
@AhmadHamad3 Dont use .upper() then...?
is it possible to send it to me in txt file @MrVoo
@AhmadHamad3 Uhhh cant you just change all .upper()s to .lower()