title: Rosalind translating rna into protein python
body: <p>Here is my solution to the <a href="http://rosalind.info/problems/prot/" rel="nofollow">problem</a> of rosalind project.</p>
  
  <pre><code>def prot(rna):
    for i in xrange(3, (5*len(rna))//4+1, 4):
      rna=rna[:i]+','+rna[i:]
    rnaList=rna.split(',')
    bases=['U','C','A','G']
    codons = [a+b+c for a in bases for b in bases for c in bases]
    amino_acids = 'FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG'
    codon_table = dict(zip(codons, amino_acids))
    peptide=[]
    for i in range (len (rnaList)):
      if codon_table[rnaList[i]]=='*':
        break
      peptide+=[codon_table[rnaList[i]]]
    output=''
    for i in peptide:
      output+=str(i)
    return output
  </code></pre>
  
  <p>If I run <code>prot('AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA')</code>, I get the correct output <code>'MAMAPRTEINSTRING'</code>. However if the sequence of rna (the input string) is hundreds of nucleotides (characters) long I got an error:</p>
  
  <pre><code> Traceback (most recent call last):
   File "&lt;stdin&gt;", line 1, in &lt;module&gt;
   File "&lt;stdin&gt;", line 11, in prot
   KeyError: 'CUGGAAACGCAGCCGACAUUCGCUGAAGUGUAG'
  </code></pre>
  
  <p>Can you point me where I went wrong?</p>