##DNA Question and using randint


My Take On The DNA to Codon caculator

This is my take on the DNA converter. I Use a direct approach by writing out all the codons instead of using functions.

#i import randint to make a randomized DNa code from random import randint #i then make variebles to make typing easier A = "A" T = "T" C = "C" G = "G" i = 0 #i make two lists for Rna and Dna SEQ = [A, T, C, G] nSEQ = [] #ask the user to input numbers length = int(input("Enter a number ")) x = len(SEQ)-1 #below this randomizes the letters for i in range(0, length): y = SEQ[randint(0, x)] nSEQ.append(y) # i = i + 1 output = [] #and this is converting to RNA by appending the Rna code to the Dna code for j in range (0, len(nSEQ)): if nSEQ[j] == A: output.append("U") elif nSEQ[j] == T: output.append("A") elif nSEQ[j] == G: output.append("C") else: output.append("G") # i am printing this out so i can find where i went wrong print(nSEQ) print(output) amino ="" #i use the join function to group every three numbers for k in range(0,len(output),3): base3list=output[k:k+3] base3str="".join(base3list) print(base3str) codon = base3str #then i right every single codon and its trio along if (codon == "GCA" or codon == "GCC" or codon == "GCC" or codon == "GCU"): amino = "A" if (codon == "UGC" or codon == "UGU"): amino = "C" if (codon == "GAC" or codon == "GAU"): amino = "D" if (codon == "GAA" or codon == "GAG"): amino = "E" if (codon == "UUC" or codon == "UUU"): amino = "F" if (codon == "GGA" or codon == "GGC" or codon == "GGG" or codon == "GGU"): amino = "G" if (codon == "CAC" or codon == "CAU"): amino = "H" if (codon == "AUA" or codon == "AUC" or codon == "AUU"): amino = "I" if (codon == "AAA" or codon == "AAG"): amino = "K" if (codon == "UUA" or codon == "UUG" or codon == "CUC" or codon == "CUA" or codon == "CUG" or codon == "CUU"): amino = "L" if (codon == "AUG"): amino = "M" if (codon == "AAC" or codon == "AAU"): amino = "N" if (codon == "CCA" or codon == "CCC" or codon == "CCG" or codon == "CCU"): amino = "P" if (codon == "CAG" or codon == "CAA"): amino = "Q" if (codon == "AGA" or codon == "AGG" or codon == "CGA" or codon == "CGC" or codon == "CGG" or codon == "CGU"): amino = "R" if (codon == "AGC" or codon == "AGU" or codon == "UCA" or codon == "UCC" or codon == "UCG" or codon == "UCU"): amino = "S" if (codon == "ACA" or codon == "ACC" or codon == "ACG" or codon == "ACU"): amino = "T" if (codon == "GUA" or codon == "GUC" or codon == "GUG" or codon == "GGU"): amino = "V" if (codon == "UGG" ): amino = "W" if (codon == "UAC" or codon == "UAU" ): amino = "Y"
1