How to alter this code to allow appending to the list?

后端 未结 3 986
春和景丽
春和景丽 2021-01-24 13:10

I have an issue appending or in fact printing anything after this block of code:

reversedPriv = [52,27,13,6,3,2]
array= [9]
var = 0
numA = []
for i in array:
            


        
3条回答
  •  长发绾君心
    2021-01-24 14:02

    I am not sure what are you trying to do, but it'seems you want 6 + 3 = 9, append 6,3 to numA

    for it1 in reversedPriv:
        for it2 in reversedPriv:
    
            sumit = it1 + it2     # sum 1st iteraction with 2nd iteraction
    
            if sumit == array[0]: #extract array value from list
    
                if it1 not in numA and it2 not in numA:
                    numA.append(it1)
                    numA.append(it2)
    
    print(numA)
    #[6, 3]
    

提交回复
热议问题