cipher encoder in python using dictionaries
<p>I'm trying to practice using dictionaries and functions on python. I am trying to write a program that encrypts a simple phrase or sentence with an encrypted alphabet: </p>

<pre><code>Original alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Encrypted alphabet: TDLOFAGJKRICVPWUXYBEZQSNMH. 
</code></pre>

<p>The user is to enter the phrase or sentence to be encrypted so it could contain upper or lowercase alphabet, spaces, commas, and periods. The output, though, should only be uppercase letters with spaces and punctuation marks. </p>

<pre><code>cipher ={"A":"T","a":"T","B":"D","b":"D","C":"L","c":"L","D":"O","d":"O","E":"F","e":"F","F":"A","f":"A","G":"G","g":"G","H":"J","h":"J","I":"K","i":"K","J":"R","j":"R","K":"I","k":"I","L":"C","l":"C","M":"V","m":"V","N":"P","n":"P","O":"W","o":"W","P":"U","p":"U","Q":"X","q":"X","R":"Y","r":"Y","S":"B","s":"B","T":"E","t":"E","U":"Z","u":"Z","V":"Q","v":"Q","W":"S","w":"S","X":"N","x":"N","Y":"M","y":"M","Z":"H","z":"H"}

def encode(str,cipher):
    result=""
    for c in str:
        result = result + cipher[c]
    return result
</code></pre>

<p>You should exclude those cases with unknown symbols and that could be done by:</p>

<pre><code>    cipher ={"A":"T","a":"T","B":"D","b":"D","C":"L","c":"L","D":"O","d":"O","E":"F","e":"F","F":"A","f":"A","G":"G","g":"G","H":"J","h":"J","I":"K","i":"K","J":"R","j":"R","K":"I","k":"I","L":"C","l":"C","M":"V","m":"V","N":"P","n":"P","O":"W","o":"W","P":"U","p":"U","Q":"X","q":"X","R":"Y","r":"Y","S":"B","s":"B","T":"E","t":"E","U":"Z","u":"Z","V":"Q","v":"Q","W":"S","w":"S","X":"N","x":"N","Y":"M","y":"M","Z":"H","z":"H"}
    def encode(words, cipher):
        result = ''
        for letter in words:
            if letter in cipher:
                result = result + cipher[letter]
            else:
                result = result + letter
        return result
phrase = raw_input('Please enter your phrase: ')
print encode(phrase, cipher)
</code></pre>

python dictionary encryption