代码:
def find_orf_lengths(dna,frame,cutoff):
orfs_lengths = []
for i in range(0,len(dna),3):
if(dna[i:i+3] == "ATG"):
orfs_lenghts[i] += 1
elif(dna[i:i+3] == "TGA"|"TAA"|"TAG"):
if(orfs_lenghts[i] >= cutoff):
orfs_lengths.append(100)
elif(orfs_lenghts[i] < cutoff):
continue
return orfs_lengths
我正在研究一个蛋白质序列项目,问题是,无论我做什么,我都可以通过&#34;预期缩进的块&#34;错误,如下所示:
File "lab6hw.py", line 27
if(dna[i:i+3] == "ATG"):
IndentationError: expected an indented block
答案 0 :(得分:2)
将elif放在相同的缩进级别,如下所示:
def find_orf_lengths(dna,frame,cutoff):
orfs_lengths = []
for i in range(0, len(dna), 3):
if(dna[i:i + 3] == "ATG"):
orfs_lenghts[i] += 1
elif(dna[i:i + 3] == "TGA" | "TAA" | "TAG"):
if(orfs_lenghts[i] >= cutoff):
orfs_lengths.append(100)
elif(orfs_lenghts[i] < cutoff):
continue
return orfs_lengths
答案 1 :(得分:1)
elif
必须与其上方的if
处于同一缩进级别。你可能意味着这样的事情:
def find_orf_lengths(dna,frame,cutoff):
orfs_lengths = []
for i in range(0,len(dna),3):
if(dna[i:i+3] == "ATG"):
orfs_lenghts[i] += 1
elif(dna[i:i+3] == "TGA"|"TAA"|"TAG"):
if(orfs_lenghts[i] >= cutoff):
orfs_lengths.append(100)
elif(orfs_lenghts[i] < cutoff):
continue
return orfs_lengths
虽然我不知道输入就无法测试你的代码。