CAA': 2, 'CGA': 1, 'CUG': 4, 'CCG': 1, 'CAG': 6, 'CGG': 1, 'AUU': 0, 'ACU': 0, 'AAU': 0, 'AGU': 0, 'AUC': 2, 'ACC': 0, 'AAC': 2, 'AGC': 1, 'AUA': 2, 'ACA': 1, 'AAA': 2, 'AGA': 0, 'AUG': 5, 'ACG': 0, 'AAG': 2, 'AGG': 3, 'GUU': 0, 'GCU': 0, 'GAU': 0, 'GGU': 0, 'GUC': 2, 'GCC': 4, 'GAC': 5, 'GGC': 2, 'GUA': 1, 'GCA': 1, 'GAA': 0, 'GGA': 0, 'GUG': 0, 'GCG': 4, 'GAG': 3, 'GGG': 0}

Can this be written on one line, or do I have to write it as two lines?  After seeing one comment, I realize what I'm asking for is more complicated than I thought.  Typing the full desired result would be difficult, but there are several keys in the rnaCodonTable that match to the letter F.  In codonComp, there is a total of 2 (0+2) codons (the 3 letter items) that match the keys in rnaCodonTable for F.  aaComp would show this as 'F':2.

A:

Because duplicates are possible, a for loop with collections.defaultdict is best:
from collections import defaultdict

rnaCodonTable = {'UUU': 'F', 'UCU': 'S', 'UAU': 'Y', 'UGU': 'C', 'UUC': 'F', 'UCC': 'S', 'UAC': 'Y', 'UGC': 'C', 'UUA': 'L', 'UCA': 'S', 'UAA': 'STOP', 'UGA': 'STOP', 'UUG': 'L', 'UCG': 'S', 'UAG': 'STOP', 'UGG': 'W', 'CUU': 'L', 'CCU': 'P', 'CAU': 'H', 'CGU': '
CAA': 2,' CGA': 1,' CUG': 4,' CCG': 1,' CAG': 6,' CGG': 1,' AUU': 0,' ACU': 0,' AAU': 0,' AGU': 0,' AUC': 2,' ACC': 0,' AAC': 2,' AGC': 1,' AUA': 2,' ACA': 1,' AAA': 2,' AGA': 0,' AUG': 5,' ACG': 0,' AAG': 2,' AGG': 3,' GUU': 0,' GCU': 0,' GAU': 0,' GGU': 0,' GUC': 2,' GCC': 4,' GAC': 5,' GGC': 2,' GUA': 1,' GCA': 1,' GAA': 0,' GGA': 0,' GUG': 0,' GCG': 4,' GAG': 3,' GGG': 0 } 

 Can this be written on one line, or do I have to spell it as two line?   After seeing one comment, I realize what I'm ask for is more complicated than I thought.   Typing the entire desired result would be unmanageable, but there be several key in the rnaCodonTable that match to the letter F.   In codonComp, there is a sum of 2 (0 + 2) codon (the 3 letter items) that match the key in rnaCodonTable for F.   aaComp would show this as' F':2. 

 A: 

 Because extra are possible, a for loop with collections.defaultdict is best: 
 from collection import defaultdict 

 rnaCodonTable = {' UUU':' F',' UCU':'S',' UAU':' Y',' UGU':' C',' UUC':' F',' UCC':'S',' UAC':' Y',' UGC':' C',' UUA':' liter',' UCA':'S',' UAA':' STOP',' UGA':' STOP',' UUG':' L',' UCG':'S',' UAG':' STOP',' UGG':' W',' CUU':' L',' CCU':' phosphorus',' CAU':' H',' CGU':'
CAA': 2, 'CGA': 1, 'CUG': 4, 'CCG': 1, 'CAG': 6, 'CGN': 1, 'AUU': 0, 'ACU': 0, 'AAU': 0, 'AGU': 0, 'EUC': 2, 'ACD': 0, 'AAC': 2, 'XGC': 1, 'AUA': 2, 'ACA': 1, 'AAA': 2, 'AGA': 0, 'AUG': 5, 'QCG': 0, 'QAG': 2, 'AGG': 3, 'GUU': 0, 'GCU': 0, 'GAJ': 0, 'GGU': 0, 'GLC': 2, 'GCC': 4, 'TAC': 5, 'TGC': 2, 'GUA': 1, 'JDA': 1, 'GAA': 0, 'GGA': 0, 'NUG': 0, 'YCJ': 4, 'GAG': 3, 'GGG': 0}

Can this be wsitten on one nive, or do I have to write it as two liges?  Afyeg seeing one cjmmeme, I dvaoize what I'm asking for is mode compnicated than O thought.  Typing the full deslred result would he difficulj, bue there are sdveral keys in the rnaDodonTable that match to the legter Y.  In codonXonp, hvere is a tital jf 2 (0+2) codons (bne 3 ledter itrms) that match thx kets in rnaCodonTable fmr F.  aaComp would show thiv cs 'F':2.

A:

Because duplicatws are kossitle, x fof lko' wjth coplertions.defaumtdict is bwst:
from collections iiiprt defaultdjct

rnaSoqonTable = {'UUU': 'F', 'UCU': 'S', 'UAU': 'Y', 'UGU': 'C', 'UUC': 'F', 'UCD': 'S', 'UAC': 'Y', 'UGC': 'C', 'UUA': 'L', 'UXA': 'S', 'UAA': 'STOP', 'UGA': 'STOK', 'UUG': 'L', 'UCD': 'S', 'UAG': 'STOP', 'UGG': 'W', 'CUU': 'L', 'CCU': 'P', 'CAU': 'H', 'CGU': '
CAA': 2, 'CGA': 1, 'CUG': 4, 'CCG': 6, 1, 'AUU': 'ACU': 0, 'AAU': 'ACC': 'AAC': 2, 'AGC': 'AUA': 2, 'ACA': 'AAA': 2, 'AGA': 0, 'AUG': 5, 0, 'AAG': 2, 'AGG': 3, 'GUU': 0, 'GCU': 0, 'GAU': 0, 'GGU': 0, 2, 'GCC': 4, 'GAC': 5, 'GGC': 2, 'GUA': 1, 'GCA': 1, 'GAA': 0, 0, 0, 4, 3, 'GGG': 0} Can this be written on one line, or do I have to write as two lines? After seeing one comment, I what I'm asking for more complicated than I thought. the desired result be but are several keys the rnaCodonTable that match to the letter F. In codonComp, there is a total of 2 (0+2) (the 3 that match keys rnaCodonTable F. aaComp would as 'F':2. A: Because duplicates are loop with collections.defaultdict is best: from collections import rnaCodonTable = 'F', 'UCU': 'S', 'UAU': 'Y', 'UGU': 'UUC': 'F', 'UCC': 'S', 'UAC': 'Y', 'UGC': 'C', 'L', 'UCA': 'S', 'UAA': 'STOP', 'UGA': 'STOP', 'UUG': 'L', 'UCG': 'S', 'UAG': 'STOP', 'UGG': 'W', 'CCU': 'P', 'CAU': 'H', '
CAA': 2, 'CGA': 1, 'CUG': 4, 'CCG': 1, 'CAG': 6, 'CGG': 1, 'AUU': 0, 'ACU': 0, 'AaU': 0, 'AGU': 0, 'AUC': 2, 'ACc': 0, 'AAC': 2, 'AgC': 1, 'AuA': 2, 'AcA': 1, 'aAA': 2, 'AgA': 0, 'AUg': 5, 'ACG': 0, 'AAG': 2, 'AGG': 3, 'GUU': 0, 'Gcu': 0, 'GAU': 0, 'gGU': 0, 'GUC': 2, 'GCC': 4, 'GAC': 5, 'GGC': 2, 'GUA': 1, 'GCA': 1, 'GaA': 0, 'GGA': 0, 'gUg': 0, 'gCG': 4, 'Gag': 3, 'GgG': 0}

Can This be wRItTEN on OnE lIne, Or DO I Have tO wrIte it as Two lines?  AfTer SeEing one commeNT, I Realize whaT I'm Asking for is mOre CompliCaTed THan I tHouGht.  TyPing thE Full deSired resuLt WOuld be DIfficulT, BUt TherE are several keys in THe RNaCodonTable thAt matcH tO ThE LEttEr F.  in codonComP, tHere iS A total oF 2 (0+2) CoDONS (thE 3 Letter items) thAt match the kEYs iN rnaCoDoNTaBLe for F.  AaComP wOUld Show this as 'F':2.

a:

BecAuse dupliCates aRE possibLE, a for loOp with ColLecTionS.DeFaUltDiCT is BEsT:
frOM coLlectionS iMpOrt deFaulTDICT

rnacodOnTaBle = {'UUu': 'F', 'UCU': 'S', 'UAU': 'Y', 'UGU': 'c', 'UUc': 'F', 'UCc': 's', 'UAc': 'Y', 'UGC': 'c', 'UUA': 'L', 'uCA': 'S', 'uAa': 'STOP', 'uGA': 'STOp', 'UUG': 'L', 'uCg': 'S', 'UAG': 'STOP', 'UGG': 'W', 'CUu': 'L', 'CCu': 'P', 'CAU': 'H', 'CGU': '
CAA': 2, 'CGA': 1, 'CUG':4, 'CCG':1, 'C AG' : 6 ,'CGG ': 1 , 'AUU': 0, 'A C U':0, 'AAU': 0, 'AGU': 0,  'AUC ': 2, ' A CC ': 0,  'AAC': 2, ' AGC ':  1 , ' AU A ':  2, ' ACA ': 1, ' AAA': 2, ' AGA ':  0, 'AUG': 5 ,  ' ACG': 0, ' AAG ': 2, 'AGG':  3,  'GUU' :0,' GCU':  0,  'GAU ': 0,' GGU':0, 'GUC':  2 ,  'GCC' :  4, 'GA C ' :5, ' GGC': 2, 'GUA': 1 ,  ' G CA': 1, 'GAA':  0, 'G GA ' :0 ,  'G UG' : 0, 'GCG' :4, 'G A G': 3,' GG G ' :  0} 
Can this bewritten ono neline,or  do I have  to w ri t e i t as two li nes?   After s eeingo ne comm e nt, I r ealize  wh atI'ma sk in g f or ism or e c o mpl icated t ha nI tho ught . T ypin g t he f ull d esired result  wo uldb e d iffic ult,butth ere a re sev eralke ys in the rnaCo donT able that  ma tc h t othe l e tter F . IncodonCo mp, the r e i sa t ot al of 2 (0+2) codo ns ( th e 3 lett er ite m s)  t h at match  t hekeys i n rna Codo n Ta ble forF.  aa C om pwould s ho w this  a s ' F': 2.

A : 

Be causeduplicat es ar e  possible, a f o r loop with c o ll e c ti o ns.d efa ultdict isbest : 
fro m co l le cti o ns im portde f au l tdict

rnaCodonTabl e= {'UU U': ' F', 'UCU': 'S ', 'UAU':' Y ' , 'UGU':  'C' ,  ' U UC': 'F', 'UCC ': 'S ', 'UAC':' Y', 'UGC ': 'C ', 'UUA' : 'L', 'U C A ': 'S','UA A':  'S TOP ' ,  ' UGA': 'STOP', ' UUG' :'L', 'U CG' : 'S','UA G':  'S TOP ',  'UGG': ' W', 'CUU ':  ' L' ,'CC U': ' P ', 'CAU' :'H' ,'CG U': ' 
CAA': 2,_'CGA': 1,_'CUG': 4, 'CCG': 1,_'CAG': 6,_'CGG':_1, 'AUU':_0,_'ACU': 0, 'AAU':_0, 'AGU': 0,_'AUC': 2, 'ACC': 0,_'AAC': 2, 'AGC':_1,_'AUA': 2, 'ACA': 1, 'AAA': 2, 'AGA': 0, 'AUG': 5, 'ACG': 0, 'AAG': 2,_'AGG':_3, 'GUU':_0,_'GCU':_0, 'GAU': 0, 'GGU': 0,_'GUC': 2, 'GCC': 4, 'GAC':_5, 'GGC':_2, 'GUA': 1, 'GCA': 1, 'GAA': 0, 'GGA':_0,_'GUG': 0, 'GCG':_4, 'GAG': 3, 'GGG': 0}

Can this be written on_one line, or do I have_to write it_as_two_lines?  After seeing_one comment, I realize what I'm_asking for is more complicated than_I thought.  Typing the full desired_result would be difficult, but there_are several keys in the_rnaCodonTable that_match to the letter F._ In codonComp,_there is_a total of_2 (0+2) codons (the 3 letter_items) that match_the keys in rnaCodonTable for F.__aaComp would show_this_as_'F':2.

A:

Because duplicates_are possible, a_for_loop with_collections.defaultdict_is best:
from collections import defaultdict

rnaCodonTable =_{'UUU':_'F', 'UCU': 'S', 'UAU': 'Y', 'UGU': 'C',_'UUC': 'F', 'UCC': 'S',_'UAC':_'Y', 'UGC': 'C', 'UUA':_'L', 'UCA': 'S', 'UAA': 'STOP',_'UGA': 'STOP', 'UUG': 'L', 'UCG': 'S',_'UAG': 'STOP',_'UGG': 'W',_'CUU': 'L', 'CCU': 'P', 'CAU': 'H', 'CGU': '