I'm trying to create a code that counts how many G's and C's there are in a "strand of DNA" and calculate the percentage of the G's + C's in that strand, e.g.
count = 0
for g in dnaMolecule:
count += 1
In : gcContent('a')
You can use the
count method that every string has.
def gcContent(dnaMolecule): dnaMolecule = dnaMolecule.lower() count = dnaMolecule.count('g') + dnaMolecule.count('c') return count / len(dnaMolecule)