I'm trying to convert the DNA code into RNA code using Python...
I write this:
print('Digite a sequência DNA a ser transcrita para RNA:')
my_str = raw_input()
print(my_str.replace('T', 'U'))
And it works, but.. now I need to convert A to U, T to A, G to C and C to G... I looked how I could do it, and did this:
print('Digite a sequência DNA a ser transcrita para RNA:')
my_str = raw_input()
RNA_compliment = {
ord('A'): 'U', ord('T'): 'A',
ord('G'): 'C', ord('C'): 'G'}
my_str.translate(RNA_compliment)
But I get this error:
Traceback (most recent call last):
File "rna2.py", line 15, in <module>
my_str.translate(RNA_compliment)
TypeError: expected a character buffer object
What i did wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…