I have a list which contains the frame, start codon position, stop codon position, sequence of the gene, and gene length . Both sequence and length are based on the start and stop. I wanted to unpack this list and add frame, start/stop positions, sequence, and gene length for genes with a certain length to another list. My code is as follows:
for framenumber, startposition, stopposition, geneseq, genelength in range(len(codonpairsfwd)):
if len(gene_seq) < 200:
GenesToRemove_Fwd.append(framenumber)
GenesToRemove_Fwd.append(startposition)
GenesToRemove_Fwd.append(stopposition)
GenesToRemove_Fwd.append(geneseq)
GenesToRemove_Fwd.append(genelength)
and I get this error message: TypeError: cannot unpack non-iterable int object for the first line(i.e. line with for loop).
Any ideas where I might be going wrong would super appreciated
framenumber, startposition, stopposition, geneseq, genelength in range(len(codonpairsfwd)). This is not how range works. Have a look at the basics. If your list already includes at indice one a tuple of those 5 desired variable, then directly iterate over the listfor v1, v2, v3, v4, v5 in L: