Caesar Cipher shift by two letters
<pre><code>def main():

    cc = (input("Enter Message to Encrypt\n"))#user input

    shift = int(2) #shift length

    a=["a","b","c","d","e","f","g","h","i","j","k","l",
       "m","n","o","p","q","r","s","t","u","v","w","x","y","z"] #reference list

    newa={} #new shifted reference list

    for i in range (0,len(a)):
        newa [a[i]]=a[(i+shift)%len(a)]
        #adds shifted 2 alaphabet into newalaphabet
        #% moodulus used to wrap

        for i in cc: #iterates through cc
            if i in a:
                    a[i]=cc[i]
                    a[i]=newa[i]

main()
</code></pre>

<p>So I need input from the user #cc</p>

<p>the shift needs to be two</p>

<p>I used an alphabet list</p>

<p>then shift the alphabet by two to create newa</p>

<p>but I do not know how to apply the new alphabet to my user's input</p>

<p>Use mapping for every char, then join them back to create the encrypted message:</p>

<pre><code>''.join(map(lambda x: chr((ord(x) - 97 + shift) % 26 + 97) if x in alphabet else x, cc.lower()))
</code></pre>

<p>Integrate it like that:</p>

<pre><code>import string
alphabet = string.ascii_lowercase
cc = input('Enter string to encode: ')
shift = 2 # could be any number

encrypted = ''.join(map(lambda x: chr((ord(x) - 97 + shift) % 26 + 97) if x in alphabet else x, cc.lower()))
</code></pre>

<p><code>cc.lower()</code> for the letters to be all same case (to map using constant <code>ord</code>)</p>

<p><code>chr((ord(x) - 97 + shift) % 26 + 97)</code> :</p>

<ul>
<li>get the value of the number minus 97 (0 for <code>a</code>, 1 for <code>b</code>, etc.).</li>
<li>apply the shift (<code>a</code> turns to <code>c</code>, etc.).</li>
<li>modulate by 26 to prevent letters like <code>z</code> from exceeding (25 + 2 = 27, 27 % 26 = 1 = <code>b</code>).</li>
<li>add 97 to bring the letter back to ascii standard (97 for <code>a</code>, 98 for <code>b</code>, etc.)</li>
</ul>

<p><code>if x in alphabet else x</code> cover for signs that are not letter (if you want to ignore spaces and punctuation use <code>if x in alphabet else ''</code> instead).</p>

python encryption caesar-cipher