I'm tasked with designing a function which recognises the length of the RNA code (excluding the start and stop codons). The function must also determine if their code is actually valid (must contain AUG as a start codon and UGA, UAA, or UAG at the end) Note: RNA starts with a start codon AUG and ends with UGA, UAA, or UAG The function must return "Not readable RNA code" if the above conditions are not met.
def rna_length(mrna):
start_trans = 'AUG'
end_trans1 = 'UAA'
end_trans2 = 'UGA'
end_trans3 = 'UAG'
if ((mrna[0:3]!=start_trans) and (mrna [-3:]!=end_trans1 or end_trans2 or end_trans3)):
return "Not readable RNA code"
else:
(mrna[0:3]==start_trans) and (mrna [-3:]==end_trans1 or end_trans2 or end_trans3)
length = len(mrna[3:-3])
return length
But this code won't work for 'AUGAGGCACCUUCUGCUCCUUAC'. It returns the length instead of "Not readable'