简体   繁体   中英

TypeError: cannot unpack non-iterable int object for list

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(ie line with for loop).

Any ideas where I might be going wrong would super appreciated

range() will list numbers (int) to loop, so you cannot unpack that number onto framenumber, startposition, stopposition, ... etc... as it's only an integer, starting from 0 and ends with len(codonparisfwd).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM