I have a program that converts DNA sequences into RNA sequences.
The translation part works fine. Where I am stuck is that I input a list of four elements, but I am getting back a list with a single element back.
My code:
dnasequences = [
'GCTAGCTAGCTAGCTA',
'CTAGCTAGCTAGCTAG',
'TAGCTAGCTAGCTAGC',
'AGCTAGCTAGCTAGCT'
]
xlate = {'G': 'C', 'C': 'G', 'T': 'A', 'A': 'U'}
def dna2rna(sequences):
rnalist = [xlate[n] for sequence in sequences for n in sequence]
return rnalist
rnasequences = dna2rna(dnasequences)
print(''.join(rnasequences))
This returns:
CGAUCGAUCGAUCGAUGAUCGAUCGAUCGAUCAUCGAUCGAUCGAUCGUCGAUCGAUCGAUCGA
The translation is correct, but I want rnasequences() to contain four 16-character elements just like the input list dnasequences().