Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2018
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Needing help with an encryption program

    I am working on a basic caeser cipher program but keep running into the typeerror for my rational expression not being supported between two instances. I am uncertain as to how to fix the problem so that the program will execute. Any advice would be welcome. I am building this program in pyton 3.7. Source code is attached below. Pre-post thanks for anyone taking time out of their day to offer an assist.

    original_string = input('Enter the string to be encrypted. ')
    key = int(input('Enter the encryption key.' ))
    lower_a = ord('a')
    lower_z = ord('z')
    upper_A = ord('A')
    upper_Z = ord('Z')
    def encryption(original_string, key):
    cipher = ''
    for x in original_string:
    if x >= lower_a and x <= lower_z:
    cipher += chr((ord(x) + key) % 26)
    elif x >= upper_A and x <= upper_Z:
    cipher += chr((ord(x) + key) % 26)
    else:
    cipher += x
    print(cipher)
    encryption(original_string, key)

  2. #2
    New to the CF scene
    Join Date
    Oct 2018
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    quick edit. the coding is indented properly but the thread posted it as above.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •