Homework assistance
I need to write a function which has the ability to take in a string containing DNA codons from a user e.g.
'ACATTTGCTTCTGACACAACTGTGTTCACTAGCAACCTCAAAC'
separate the string into groups of 3, then match each group with the dictionary items. but the program must only print out the keys, not the values.
input: ATTGHIATGTTTTTCTYU
separation:[ATT] [GHI] [ATG] [TTT] [TTC] [TYU]
output: IMFF
This is what I have so far
dna_codons = {'I': 'ATT' 'ATC' 'ATA',
'L': 'CTT' 'CTC' 'CTA' 'CTG' 'TTA' 'TTG',
'V': 'GTT' 'GTC' 'GTA' 'GTG',
'F': 'TTT' 'TTC',
'M': 'ATG',
}
def translate(sequence):
n = 3
MyList = [sequence[i:i+n] for i in range(0, len(sequence), n)]
for codon in MyList:
for slc in dna_codons.keys():
if codon == slc:
print slc
print translate(raw_input('type in DNA sequence: '))