warszawiaczek
warszawiaczek

Reputation: 1

Write functions counting the DNA sequence of codon " ATG "

the content of my tasks are "Write functions counting the DNA sequence of codon " ATG "

I did something like that but I do not know what is wrong with that

def seq(dna):
    dna = dna.count("ATG")

print seq("ATGSDSGFAGEFRASFWET")

Please help me

Upvotes: 0

Views: 673

Answers (2)

Bear
Bear

Reputation: 572

i'm guessing you forgot to add return?

def seq(dna):
    dna = dna.count("ATG")
    return dna

print seq("ATGSDSGFAGEFRASFWET")

Upvotes: 0

Victor Viola
Victor Viola

Reputation: 585

1 - Strip your major string in a array of strings with size 3.

2 - Do an iteration in your array of strings and compare with string "ATG" - If the comparison is true, increment in 1 an int auxiliar variable

3 - Display the result of the auxiliar int variable

Upvotes: 1

Related Questions