title: How to encrypt strings in python
body: <p>I'm having trouble with this function.
  def encrypt(msg, code):
      '''(str, str) -> str
      Return msg encrypted using the given code.  The code
      is an ordering of the alphabet plus the space and '.' 
      characters. The position of each character in the code
      string gives the index of the replacement character in 
      the regular alphabet 'abcdefghijklmnopqrstuvwxyz .'  </p>
  
  <pre><code>In the first example below, 'h' is in position 20, so we 
  select the letter in position 20 in the alphabet, or 'u'.
  
  &gt;&gt;&gt; encrypt('hello there', '. zyxwvutsrqponmlkjihgfedcba')
  'uxqqnbiuxkx'
  &gt;&gt;&gt; encrypt('hello there', '. zaybxcwdveuftgshriqjpkolnm')
  'rlzzyborlsl'
  '''
  alpha = 'abcdefghijklmnopqrstuvwxyz'
  i = 0
  for char in len(msg[i]):
      if msg[i] == code and msg[i] == alpha[i]:
          return msg
  </code></pre>
  
  <p>I have that, but it doesn't work. Can anybody help me out please?</p>