Answer:
In python:
def dna_count(dna):
A = dna.count('A'); C = dna.count('C')
G = dna.count('G'); T = dna.count('T')
dna_countlist = []
dna_countlist.append(A) dna_countlist.append(C)
dna_countlist.append(G) dna_countlist.append(T)
return dna_countlist
dna = input("DNA: ")
print(dna_count(dna))
Step-by-step explanation:
This defines the function
def dna_count(dna):
This counts the occurrence of A and C
A = dna.count('A'); C = dna.count('C')
This counts the occurrence of G and T
G = dna.count('G'); T = dna.count('T')
This creates an empty list
dna_countlist = []
This appends the occurrence of A and C to the empty list
dna_countlist.append(A) dna_countlist.append(C)
This appends the occurrence of G and T to the list
dna_countlist.append(G) dna_countlist.append(T)
This returns the list
return dna_countlist
The main begins here
This prompts the user for the DNA string
dna = input("DNA: ")
This calls the dna_count function and also prints the returned list
print(dna_count(dna))