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>I'll throw my solution in there. It should be pretty clear how it works...</p>

<pre><code>import string

index_lookup = {letter: index for index, letter in enumerate(string.ascii_lowercase)}

def caesar_letter(l, shift=2):
    new_index = index_lookup[l] + shift
    return string.ascii_lowercase[new_index % len(index_lookup)]

def caesar_word(s):
    return ''.join([caesar_letter(letter) for letter in s])
</code></pre>

<p>I think the above is better for readability but if you're opposed to imports...</p>

<pre><code>index_lookup = {chr(idx): idx - ord('a') for idx in range(ord('a'), ord('z')+1)}
</code></pre>

<p>...</p>

<pre><code>In [5]: caesar_word('abcdefghijklmnopqrstuvwxyz')
Out[5]: 'cdefghijklmnopqrstuvwxyzab'
</code></pre>

python encryption caesar-cipher