CodeWars "Dbftbs Djqifs" kata code I have been working on the following kata from CodeWars. It's basically a Caesar Cipher — see the test cases below my solution code. 

Any comments/feedback appreciated! 

def encryptor(key, message):
    new = ""
    for letter in message:
        if letter.isalpha():
            id = ord(letter)
            shift = id+key 
            if 97 &lt;= id &lt;= 122: 
                while shift&gt;122:
                    shift -= 26
                while shift&lt;97:
                    shift += 26    
                letter = chr(shift)
            if 65 &lt;= id &lt;= 90: 
                while shift&gt;90:
                    shift -= 26
                while shift&lt;65:
                    shift += 26    
                letter = chr(shift)
        new = new + letter
    return new 


And here are test cases that give you an idea of what is being looked for: 

test.assert_equals(encryptor(13, ''), '')
test.assert_equals(encryptor(13, 'Caesar Cipher'), 'Pnrfne Pvcure')
test.assert_equals(encryptor(-5, 'Hello World!'), 'Czggj Rjmgy!')
test.assert_equals(encryptor(27, 'Whoopi Goldberg'), 'Xippqj Hpmecfsh')
There is not too much to be said about the code as it is. A few (very minor) things I can point out as suggestions:


Make if 97 &lt;= id &lt;= 122: followed by if 65 &lt;= id &lt;= 90: an if-elif clause. That makes it clearer the code path can only follow one of these (or even neither).
Dedent the bottom letter = chr(shift) by one indentation and remove the other one; avoids duplication
There is inconsistent white space around operators (sometimes one space each side, sometimes no space). I think PEP 8 recommends a single space on each side. 
Some people will argue that you shouldn't do new = ""; ... ; new = new + letter. But instead, something like letters = []; ...; letters.append(letter); ...; new = "".join(letters).
That would gain you some speed. But only if your string becomes (very) long. For small strings, I think the current way (appending to a string) is clearer.
Just so you know.




I can, however, suggest to use str.maketrans and str.translate. 
 You'll need to set up the translation table in a smart way (the algorithm), but the actually encoding is then very clear and straightforward. Left as an exercise to the reader.

Which leads to the fun fact: rot13 is available as a standard encoding. 
In Python 2:

&gt;&gt;&gt; 'Caesar Cipher'.encode('rot13')
'Pnrfne Pvcure'


In Python 3 is slight more effort:

&gt;&gt;&gt; import codecs
&gt;&gt;&gt; codecs.encode('Caesar Cipher', 'rot13')
'Pnrfne Pvcure'