The central dogma of molecular biology is that DNA is transcribed into RNA, which is then tranlsated into protein. RNA, like DNA, is a long strand of nucleic acids held together by a sugar backbone (ribose in this case). Each segment of three bases is called a codon. Molecular machines called ribosomes translate the RNA codons into amino acid chains, called polypeptides which are then folded into a protein. 

Protein sequences are easily visualized in much the same way that DNA and RNA are, as large strings of letters. An important thing to note is that the 'Stop' codons do not encode for a specific amino acid. Their only function is to stop translation of the protein, as such they are not incorporated into the polypeptide chain. 'Stop' codons should not be in the final protein sequence. To save a you a lot of unnecessary (and boring) typing the keys and values for your amino acid dictionary are provided.
                         
Given a string of RNA, create a funciton which translates the RNA into its protein sequence. Note: the test cases will always produce a valid string.

```python
protein('UGCGAUGAAUGGGCUCGCUCC') returns 'CDEWARS'
```

Included as test cases is a real world example! The last example test case encodes for a protein called green fluorescent protein; once spliced into the genome of another organism, proteins like GFP allow biologists to visualize cellular processes!

Amino Acid Dictionary
----------------------

```python
    # Phenylalanine
    'UUC':'F', 'UUU':'F',
    # Leucine
    'UUA':'L', 'UUG':'L', 'CUU':'L', 'CUC':'L','CUA':'L','CUG':'L', 
    # Isoleucine
    'AUU':'I', 'AUC':'I', 'AUA':'I', 
    # Methionine
    'AUG':'M', 
    # Valine
    'GUU':'V', 'GUC':'V', 'GUA':'V', 'GUG':'V', 
    # Serine
    'UCU':'S', 'UCC':'S', 'UCA':'S', 'UCG':'S', 'AGU':'S', 'AGC':'S', 
    # Proline
    'CCU':'P', 'CCC':'P', 'CCA':'P', 'CCG':'P', 
    # Threonine
    'ACU':'T', 'ACC':'T', 'ACA':'T', 'ACG':'T',
    # Alanine
    'GCU':'A', 'GCC':'A', 'GCA':'A', 'GCG':'A', 
    # Tyrosine
    'UAU':'Y', 'UAC':'Y', 
    # Histidine
    'CAU':'H', 'CAC':'H',
    # Glutamine
    'CAA':'Q', 'CAG':'Q', 
    # Asparagine
    'AAU':'N', 'AAC':'N', 
    # Lysine
    'AAA':'K', 'AAG':'K',
    # Aspartic Acid
    'GAU':'D', 'GAC':'D', 
    # Glutamic Acid
    'GAA':'E', 'GAG':'E',
    # Cystine
    'UGU':'C', 'UGC':'C',
    # Tryptophan
    'UGG':'W', 
    # Arginine
    'CGU':'R', 'CGC':'R', 'CGA':'R', 'CGG':'R', 'AGA':'R', 'AGG':'R', 
    # Glycine
    'GGU':'G',  'GGC':'G', 'GGA':'G', 'GGG':'G', 
    # Stop codon
    'UAA':'Stop', 'UGA':'Stop', 'UAG':'Stop'
```

Difficulty: introductory

Starter code:

def protein(rna):
	

Solutions:
import re
dict = {'UUC':'F','UUU':'F','UUA':'L','UUG':'L','CUU':'L','CUC':'L','CUA':'L','CUG':'L','AUU':'I','AUC':'I','AUA':'I','AUG':'M','GUU':'V','GUC':'V','GUA':'V','GUG':'V','UCU':'S','UCC':'S','UCA':'S','UCG':'S','AGU':'S','AGC':'S','CCU':'P','CCC':'P','CCA':'P','CCG':'P','ACU':'T','ACC':'T','ACA':'T','ACG':'T','GCU':'A','GCC':'A','GCA':'A','GCG':'A','UAU':'Y','UAC':'Y','CAU':'H','CAC':'H','CAA':'Q','CAG':'Q','AAU':'N','AAC':'N','AAA':'K','AAG':'K','GAU':'D','GAC':'D','GAA':'E','GAG':'E','UGU':'C','UGC':'C','UGG':'W','CGU':'R','CGC':'R','CGA':'R','CGG':'R','AGA':'R','AGG':'R','GGU':'G','GGC':'G','GGA':'G','GGG':'G'}

def protein(rna):
    return re.sub('.{3}', lambda r: dict.get(r.group(0), ''), rna)

from re import findall
def protein(rna):
    return "".join({'UUC':'F', 'UUU':'F',
    'UUA':'L', 'UUG':'L', 'CUU':'L', 'CUC':'L','CUA':'L','CUG':'L', 
    'AUU':'I', 'AUC':'I', 'AUA':'I', 
    'AUG':'M', 
    'GUU':'V', 'GUC':'V', 'GUA':'V', 'GUG':'V', 
    'UCU':'S', 'UCC':'S', 'UCA':'S', 'UCG':'S', 'AGU':'S', 'AGC':'S', 
    'CCU':'P', 'CCC':'P', 'CCA':'P', 'CCG':'P', 
    'ACU':'T', 'ACC':'T', 'ACA':'T', 'ACG':'T',
    'GCU':'A', 'GCC':'A', 'GCA':'A', 'GCG':'A', 
    'UAU':'Y', 'UAC':'Y', 
    'CAU':'H', 'CAC':'H',
    'CAA':'Q', 'CAG':'Q', 
    'AAU':'N', 'AAC':'N', 
    'AAA':'K', 'AAG':'K',
    'GAU':'D', 'GAC':'D', 
    'GAA':'E', 'GAG':'E',
    'UGU':'C', 'UGC':'C',
    'UGG':'W', 
    'CGU':'R', 'CGC':'R', 'CGA':'R', 'CGG':'R', 'AGA':'R', 'AGG':'R', 
    'GGU':'G',  'GGC':'G', 'GGA':'G', 'GGG':'G', 
    'UAA':'', 'UGA':'', 'UAG':''}.get(x) for x in findall("...", rna))

import re

def protein(rna):
    rna_2_protein_dict = {
    # Phenylalanine
    'UUC':'F', 'UUU':'F',
    # Leucine
    'UUA':'L', 'UUG':'L', 'CUU':'L', 'CUC':'L','CUA':'L','CUG':'L', 
    # Isoleucine
    'AUU':'I', 'AUC':'I', 'AUA':'I', 
    # Methionine
    'AUG':'M', 
    # Valine
    'GUU':'V', 'GUC':'V', 'GUA':'V', 'GUG':'V', 
    # Serine
    'UCU':'S', 'UCC':'S', 'UCA':'S', 'UCG':'S', 'AGU':'S', 'AGC':'S', 
    # Proline
    'CCU':'P', 'CCC':'P', 'CCA':'P', 'CCG':'P', 
    # Threonine
    'ACU':'T', 'ACC':'T', 'ACA':'T', 'ACG':'T',
    # Alanine
    'GCU':'A', 'GCC':'A', 'GCA':'A', 'GCG':'A', 
    # Tyrosine
    'UAU':'Y', 'UAC':'Y', 
    # Histidine
    'CAU':'H', 'CAC':'H',
    # Glutamine
    'CAA':'Q', 'CAG':'Q', 
    # Asparagine
    'AAU':'N', 'AAC':'N', 
    # Lysine
    'AAA':'K', 'AAG':'K',
    # Aspartic Acid
    'GAU':'D', 'GAC':'D', 
    # Glutamic Acid
    'GAA':'E', 'GAG':'E',
    # Cystine
    'UGU':'C', 'UGC':'C',
    # Tryptophan
    'UGG':'W', 
    # Arginine
    'CGU':'R', 'CGC':'R', 'CGA':'R', 'CGG':'R', 'AGA':'R', 'AGG':'R', 
    # Glycine
    'GGU':'G',  'GGC':'G', 'GGA':'G', 'GGG':'G', 
    # Stop codon
    #'UAA':'Stop', 'UGA':'Stop', 'UAG':'Stop',
}
    # your code here
    return re.sub('(?P<rna>\D{3})',lambda match_obj: rna_2_protein_dict.get(match_obj.group('rna')) ,rna)

rnaDict = '''Phenylalanine (F): UUU, UUC
Leucine (L): UUA, UUG, CUU, CUC, CUA, CUG
Isoleucine (I): AUU, AUC, AUA
Methionine (M): AUG
Valine (V): GUU, GUC, GUA, GUG
Serine (S): UCU, UCC, UCA, UCG, AGU, AGC
Proline (P): CCU, CCC, CCA, CCG
Threonine (T): ACU, ACC, ACA, ACG
Alanine(A): GCU, GCC, GCA, GCG
Tyrosine (Y): UAU, UAC
Histidine (H): CAU, CAC
Glutamine (Q): CAA, CAG
Asparagine (N): AAU, AAC
Lysine (K): AAA, AAG
Aspartic Acid (D): GAU, GAC
Glutamic Acid (E): GAA, GAG
Cysteine (C): UGU, UGC
Tryptophan (W): UGG
Artinine (R): CGU, CGC, CGA, CGG, AGA, AGG
Glycine (G): GGU, GGC, GGA, GGG
Stop Codon ('Stop'): UGA, UAA, UAG'''

import re
def protein(rna):
    transDict = {}
    for line in rnaDict.split('\n'):
        for section in line[line.index(':')+1:].replace(' ','').split(','):     
            transDict[section] = re.findall(r'\(+\'?(\w+)',line)[0]
    codec = ''
    while len(rna) > 0:
        if transDict[rna[:3]] == 'Stop':
            pass
        else:
            codec += transDict[rna[:3]]
        rna = rna[3:]
    return codec

from itertools import takewhile
from textwrap import wrap


def protein(rna):
    return "".join(PEPTIDES[codon] for codon in takewhile(PEPTIDES.__contains__, wrap(rna, 3)))


PEPTIDES = {
    'UUC':'F', 'UUU':'F',
    'UUA':'L', 'UUG':'L', 'CUU':'L', 'CUC':'L','CUA':'L','CUG':'L', 
    'AUU':'I', 'AUC':'I', 'AUA':'I', 
    'AUG':'M', 
    'GUU':'V', 'GUC':'V', 'GUA':'V', 'GUG':'V', 
    'UCU':'S', 'UCC':'S', 'UCA':'S', 'UCG':'S', 'AGU':'S', 'AGC':'S', 
    'CCU':'P', 'CCC':'P', 'CCA':'P', 'CCG':'P', 
    'ACU':'T', 'ACC':'T', 'ACA':'T', 'ACG':'T',
    'GCU':'A', 'GCC':'A', 'GCA':'A', 'GCG':'A', 
    'UAU':'Y', 'UAC':'Y', 
    'CAU':'H', 'CAC':'H',
    'CAA':'Q', 'CAG':'Q', 
    'AAU':'N', 'AAC':'N', 
    'AAA':'K', 'AAG':'K',
    'GAU':'D', 'GAC':'D', 
    'GAA':'E', 'GAG':'E',
    'UGU':'C', 'UGC':'C',
    'UGG':'W', 
    'CGU':'R', 'CGC':'R', 'CGA':'R', 'CGG':'R', 'AGA':'R', 'AGG':'R', 
    'GGU':'G',  'GGC':'G', 'GGA':'G', 'GGG':'G', 
}

def protein(s):
    d = {'UUC': 'F', 'UUU': 'F',

     'UUA': 'L', 'UUG': 'L', 'CUU': 'L', 'CUC': 'L', 'CUA': 'L', 'CUG': 'L',

     'AUU': 'I', 'AUC': 'I', 'AUA': 'I',

     'AUG': 'M',

     'GUU': 'V', 'GUC': 'V', 'GUA': 'V', 'GUG': 'V',

     'UCU': 'S', 'UCC': 'S', 'UCA': 'S', 'UCG': 'S', 'AGU': 'S', 'AGC': 'S',

     'CCU': 'P', 'CCC': 'P', 'CCA': 'P', 'CCG': 'P',

     'ACU': 'T', 'ACC': 'T', 'ACA': 'T', 'ACG': 'T',

     'GCU': 'A', 'GCC': 'A', 'GCA': 'A', 'GCG': 'A',

     'UAU': 'Y', 'UAC': 'Y',

     'CAU': 'H', 'CAC': 'H',

     'CAA': 'Q', 'CAG': 'Q',

     'AAU': 'N', 'AAC': 'N',

     'AAA': 'K', 'AAG': 'K',

     'GAU': 'D', 'GAC': 'D',

     'GAA': 'E', 'GAG': 'E',

     'UGU': 'C', 'UGC': 'C',

     'UGG': 'W',

     'CGU': 'R', 'CGC': 'R', 'CGA': 'R', 'CGG': 'R', 'AGA': 'R', 'AGG': 'R',

     'GGU': 'G', 'GGC': 'G', 'GGA': 'G', 'GGG': 'G',

     'UAA': 'Stop', 'UGA': 'Stop', 'UAG': 'Stop'}
    
    li = []
    for i in range(0, len(s), 3):
        r = d[s[i:i + 3]]
        if r == 'Stop' : break
        li.append(r)
    return ''.join(li)

def protein(rna):
    dict = { 
        # Phenylalanine
        'UUC':'F', 'UUU':'F',
        # Leucine
        'UUA':'L', 'UUG':'L', 'CUU':'L', 'CUC':'L','CUA':'L','CUG':'L', 
        # Isoleucine
        'AUU':'I', 'AUC':'I', 'AUA':'I', 
        # Methionine
        'AUG':'M', 
        # Valine
        'GUU':'V', 'GUC':'V', 'GUA':'V', 'GUG':'V', 
        # Serine
        'UCU':'S', 'UCC':'S', 'UCA':'S', 'UCG':'S', 'AGU':'S', 'AGC':'S', 
        # Proline
        'CCU':'P', 'CCC':'P', 'CCA':'P', 'CCG':'P', 
        # Threonine
        'ACU':'T', 'ACC':'T', 'ACA':'T', 'ACG':'T',
        # Alanine
        'GCU':'A', 'GCC':'A', 'GCA':'A', 'GCG':'A', 
        # Tyrosine
        'UAU':'Y', 'UAC':'Y', 
        # Histidine
        'CAU':'H', 'CAC':'H',
        # Glutamine
        'CAA':'Q', 'CAG':'Q', 
        # Asparagine
        'AAU':'N', 'AAC':'N', 
        # Lysine
        'AAA':'K', 'AAG':'K',
        # Aspartic Acid
        'GAU':'D', 'GAC':'D', 
        # Glutamic Acid
        'GAA':'E', 'GAG':'E',
        # Cystine
        'UGU':'C', 'UGC':'C',
        # Tryptophan
        'UGG':'W', 
        # Arginine
        'CGU':'R', 'CGC':'R', 'CGA':'R', 'CGG':'R', 'AGA':'R', 'AGG':'R', 
        # Glycine
        'GGU':'G',  'GGC':'G', 'GGA':'G', 'GGG':'G', 
        # Stop codon
        'UAA':'Stop', 'UGA':'Stop', 'UAG':'Stop'
    }
    arr = [rna[i:i+3] for i in range(0, len(rna), 3)]
    p = []
    for a in arr:
        if dict[a] != "Stop":
            p.append(dict[a])
        else:
            break
    return "".join(p)

MAPPING = {
  'UUC':'F', 'UUU':'F',
  'UUA':'L', 'UUG':'L', 'CUU':'L', 'CUC':'L','CUA':'L','CUG':'L', 
  'AUU':'I', 'AUC':'I', 'AUA':'I', 
  'AUG':'M', 
  'GUU':'V', 'GUC':'V', 'GUA':'V', 'GUG':'V', 
  'UCU':'S', 'UCC':'S', 'UCA':'S', 'UCG':'S', 'AGU':'S', 'AGC':'S', 
  'CCU':'P', 'CCC':'P', 'CCA':'P', 'CCG':'P', 
  'ACU':'T', 'ACC':'T', 'ACA':'T', 'ACG':'T',
  'GCU':'A', 'GCC':'A', 'GCA':'A', 'GCG':'A', 
  'UAU':'Y', 'UAC':'Y', 
  'CAU':'H', 'CAC':'H',
  'CAA':'Q', 'CAG':'Q', 
  'AAU':'N', 'AAC':'N', 
  'AAA':'K', 'AAG':'K',
  'GAU':'D', 'GAC':'D', 
  'GAA':'E', 'GAG':'E',
  'UGU':'C', 'UGC':'C',
  'UGG':'W', 
  'CGU':'R', 'CGC':'R', 'CGA':'R', 'CGG':'R', 'AGA':'R', 'AGG':'R', 
  'GGU':'G',  'GGC':'G', 'GGA':'G', 'GGG':'G', 
  'UAA':'Stop', 'UGA':'Stop', 'UAG':'Stop'
}

def protein(rna):
  return ''.join(MAPPING[rna[i:i+3]] for i in range(0, len(rna), 3)).split('Stop')[0]