Hi everyone!
Can someone help me with this little problem? I am trying to look for the position of the first nucleotide of a metionine codon (or a start codon, whatever you like). For that reason, I am using for and if in this way (here is my code):
s_otro_dna = str(otro_dna)
donde_M = []
for i in range(0,len(s_otro_dna),3):
codon = s_otro_dna[i:i+3]
if (codon==['ATG']):
donde_M.append(i)
Note: The type of the variable where I saved the sequence is string
This code doesn't give me any error message. However, when I try to look what is inside the list "donde_M" (where it is supposed to be the positions), Python "says" that is empty:
donde_M
Out[37]: []
What I am doing wrong? Thank you for your help!! :)
Replace
codon==['ATG']
withcodon=='ATG'
.I tried and the output that python gives me is the same
The approach seems like it works to me:
As alex points out, you don't need the
[ ]
or the( )
for that matter, in yourif
Than you for your answer, but it also doesn't work. I've been investigating and the problem is within the if condition, it is something wrong.
Because
i
is anint
and if you don't cast it to astr
first, print will complain.If you're printing
i
only, its not strictly necessary, but I usually print these things within other strings, so its just a habit I'm in.Then something is wrong elsewhere in your code, because that works absolutely fine for me.