jeudi 22 novembre 2018

List index out of range? If statement

I have a truly puzzling issue Im using some nested if statements to produce a list, using variables from lists

if List1[0] or List2[0] or List3[0] or List4[0] or List5[0] == 'Something':

Now my assumption is that it would check for a value in either spot to be my specific word, then continue to the next statement if not, however it stops here.

here's a little bit more of the breakdown so you can see my goal here

for i in range(5):
    if List1[0] or List2[0] or List3[0] List4[0] or List5[0] == 'Something':
        SuperList.append('example1, example2, example3')
        if List1[0] == 'Something':
            List1.remove('Something')
        elif List2[0] == 'Something':
            List2.remove('Something')
        elif List3[0] == 'Something':
            List3.remove('Something')
        elif List4[0] == 'Something':
            List4.remove('Something')
        elif List5[0] == 'Something':
            List5.remove('Something')
    elif List1[0] or List2[0] or List3[0] or List4[0] or List5[0] == 'SomethingElse':ECT.....

Anyway, i know for certain that all lists 1-5 contain exactly 1 Word, as i had my program print them all too me prior to the long if/nested if function to come

Any help would be greatly appreciated

Aucun commentaire:

Enregistrer un commentaire