0

I've this code:

for i in range(0, len(codiceCassExcel)):
count1step += 1
 for j in range(0, len(vwLinesToList)):
    if data_reg[i] == vwLinesToList[j][1]:
        if codiceCassExcel[i] == vwLinesToList[j][0]:
            #Gestione movimento diverso da 601 e non bolle nostre
            if tipo_mov[i] != 601 and len(vwLinesToList[j][7]) != 8:
                count2step += 1
                if ((int(qta_movimentata[i]) + int(vwLinesToList[j][4])) != 0) or ((int(-qta_movimentata[i]) + int(vwLinesToList[j][3])) != 0):
                    imballoColumnIn.append(vwLinesToList[j][0]),
                    dateColumnIn.append(vwLinesToList[j][1]),
                    absColumnIn.append(vwLinesToList[j][2]),
                    inColumnIn.append(vwLinesToList[j][3]),
                    outColumnIn.append(vwLinesToList[j][4]),
                    ddtColumnIn.append(vwLinesToList[j][7]),
                    wkColumnIn.append(vwLinesToList[j][8])
            elif vwLinesToList[j][7] == bolla_excel[i]:
                if ((int(qta_movimentata[i]) + int(vwLinesToList[j][4])) != 0) or (
                    (int(-qta_movimentata[i]) + int(vwLinesToList[j][3])) != 0):
                    imballoColumn.append(vwLinesToList[j][0]),
                    dateColumn.append(vwLinesToList[j][1]),
                    absColumn.append(vwLinesToList[j][2]),
                    inColumn.append(vwLinesToList[j][3]),
                    outColumn.append(vwLinesToList[j][4]),
                    ddtColumn.append(vwLinesToList[j][7]),
                    wkColumn.append(vwLinesToList[j][8])

I've 5 lists with hundred of items and a lists with similar items (vwLinesToLists). I want to check if:

firstListItem[i] and secondListItem[i](and so on...) is equal to
vwLinesToList[j][1],  vwLinesToList[j][2], vwLinesToList[j][3]
If it's true, check if nListItem - vwLinesToList[j][6] != 0:
append each vwLinesToList[item] to separate list

I need an hint about write my code without all this nested stuff. Thank you in advance

1
  • Do you know about zip? Commented Jul 29, 2016 at 10:24

1 Answer 1

1

Use zip method to iterate over your lists. See zip lists in python for code samples.

Also consider using of izip_longest function which may be useful to...

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! Sure the zip function Will help me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.