I am encountering issues in python with the if function in an exercise for my computer programming class in college, and am running into a problem with the 2nd if statement in the following program. It says that there is a syntax error:
my_text = input("enter plaintext: ")
distance = int(input("enter distance: "))
def caesar(my_text , distance)
for ch in my_text:
if ch.isalpha():
alphabet = ord(ch) + distance
if alphabet < 26:
alphabet -=26
else:
alphabet = (alphabet)%26
final_letter = chr(alphabet)
ciphertext = ""
ciphertext += final_letter
print (("cipher text is: ") , ciphertext
return (ciphertext)
caesar(my_text , distance)
The assignment is to write a code for using the caesar cipher to encrypt messages. Thanks, and please let me know if there are an other mistakes, as I am new to python and am prone to making mistakes
Aucun commentaire:
Enregistrer un commentaire