0

The code:

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         

I was working on a protein sequence project and the problem is, whatever I do I can't get past the "Expected an indented block" error which is given like this:

             File "lab6hw.py", line 27
               if(dna[i:i+3] == "ATG"):
            IndentationError: expected an indented block
Vadim
  • 4,219
  • 1
  • 29
  • 44
ItsSheriff
  • 15
  • 4

2 Answers2

2

Put elif at same indent level as 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  
Brenden Petersen
  • 1,993
  • 1
  • 9
  • 10
Nache
  • 231
  • 1
  • 7
1

An elif has to be at the same indentation level as an if above it. You probably meant something like this:

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  

Though I can't test your code without knowing the inputs.

Brenden Petersen
  • 1,993
  • 1
  • 9
  • 10