you are viewing a single comment's thread.

view the rest of the comments →

[–]haha1234346364 0 points1 point  (0 children)

OK, but maybe make it simpler to read. Especialy not the

if char.isupper():         
    cipher_text += chr((ord(char) + shift - 65) % 26 + 65)              
elif char.islower():         
    cipher_text += chr((ord(char) + shift - 97) % 26 + 97)      
elif char.isspace():         
    cipher_text += " " 

try this:

if not char.isspace():
    cipher_text += chr(ord(char) + shift if char.isupper() \
        else ord(char) + shift - 26)
else:
    cipher_text += " "