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>Iterate through the string <code>cc</code> and replace all the alphabets using the <code>get</code> method of <code>newa</code>. Characters that are not in the dictionary are left as is, by passing them as the default to <code>newa.get</code> when the key is missing: </p>

<pre><code>newa = {}
for i, x in enumerate(a):
    newa[x] = a[(i+shift) % len(a)]

encrypted_text = ''.join(newa.get(i, i) for i in cc)
</code></pre>

<p>Python's builtin <a href="https://docs.python.org/2/library/functions.html#enumerate" rel="nofollow"><code>enumerate</code></a> can be used in place of <code>range(len(a))</code> in this case where you need the items in <code>a</code> and their respective indices.</p>

python encryption caesar-cipher