mercredi 30 juin 2021

If statement within a loop, result always returning True

First post and I'm sorry if this is a very beginner error but I've been scratching my head over this all evening and can't for the life of me work out what the issue is.

I'm trying to run the below if statement within a double for loop which is iterating through a list and can't get it to return false. I've tried looking it up and thought it may be a data type comparison issue but I've double checked that (hence why everything is declared as an int) and it doesn't seem to be an issue. Everything is in integers so I'm sadly a bit lost!

Any help you can give would be most appreciated! Thankyou!

for search_site in range(len(search_list)):
    for product in range(len(product_list)):
        if search_site != int(1) or int(10) or int(13):
            print(search_site)
            print("True")
        else:
            print("False")

I've used the prints to see what's being compared and I generally get something like this (duplicates deleted for simplicity sake):

0 True 1 True 2 True 3 True 4 True 5 True 6 True 7 True 8 True 9 True 10 True 11 True 12 True 13 True

Aucun commentaire:

Enregistrer un commentaire