Can someone help me with this?

## caesar.py
def encode(msg, shift):
  
newmsg = “”
  
#process each character in msg.
#Hint: using a for loop
  
#A for loop to check each ch in msg:
if ('A'
#encode the character based on the shift number
   #Hint: the new character newch should be
#chr((ord(ch) – ord('A') + shift) % 26 + ord('A'))
  
elif ('a'
#Hint: Do similar thing to the above transformation
  
else: #if the character is not alphabetic
#Hint: What does the assignment ask you to do with such character?
  
#After the character is transformed, not put it as part of the new message
#Hint: which variables hold the new message and new character?
  

return newmsg

msg = input(“Enter message to be encrypted: “)
shiftstr = input(“Enter shift amount (1-25): “)
shift = int(shiftstr)

print(“Encrypted message: ” + encode(msg, shift))



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *