Here is the code
def has_stop(dna,frame) :
stop_codon_found=False
stop_codons =['tga','tag','taa']
for i in range(frame,len(dna),3) :
codon =dna[i:i+3].lower()
if codon in stop_codons:
stop_codon_found=True
break
Return stop_codon_found
Python Jupyter notebook turn 'break' in RED. Why? and running it gives "File "", line 10 Return stop_codon_found ^ SyntaxError: invalid syntax
Well, if I move 'break' one space to the left, leaving the letter b in 'break' sticking out and lining up r in 'break' with s in 'stop_codon_found', break turns GREEN. It of course says "unindent does not match any outer indentation level". If I hit one indentation to the right, 'break' also turns GREEN, but it says 'unexpected indent'
What is going on?
Try:
def has_stop(dna,frame) :
stop_codon_found=False
stop_codons =['tga','tag','taa']
for i in range(frame,len(dna),3) :
codon =dna[i:i+3].lower()
if codon in stop_codons:
stop_codon_found=True
break
return stop_codon_found
In order to have your return
within the function it has to be one indentation level under def ...
. Also it's return
not Return