I have used strings rather than converting strings to ASCII I felt it easier
defencrypt(message, shift_number):
''' parameter: message, shift_number returns : encrypted_result just encrypts the message '''total_possibilities='abcdefghijklmnopqrstuvwxyz'encrypted_result=''forcharacterinmessage:
index=total_possibilities.find(character.lower())
ifindex==-1:
encrypted_result+=characterelse:
output_index= (index+shift_number) %len(total_possibilities)
encrypted_result+=total_possibilities[output_index]
returnencrypted_result.upper()
defdecrypt(message, shift_number):
''' parameter: message, shift_number returns: decrypted_result just decrupts the message '''total_possibilities='abcdefghijklmnopqrstuvwxyz'decrypted_result=''forcharacterinmessage:
index=total_possibilities.find(character.lower())
ifindex==-1:
decrypted_result+=characterelse:
output_index= (index-shift_number) %len(total_possibilities)
decrypted_result+=total_possibilities[output_index]
returndecrypted_result.upper()