148k views
5 votes
Write a program whose input is a DNA sequence (a string), and whose output indicates the number of times the nucleotide base 'g' is found in the sequence.

Ex: If the input is:
agtctstcgtatgg

the output is:
4

Ex: If the input is:
gctgcgtttgggtagt

the output is:
7

User Omniwombat
by
4.1k points

1 Answer

5 votes

in python:

dna = (whatever the DNA sequence is)

print(dna.count('g'))

I hope this helps!

User Jhonn
by
4.1k points