Python Forum

Full Version: Can I check multi condition for 1 item in a easy way?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I want to check if 1 item apper in 4 lists
right now this is how I do this:
if item is not None and item is not False and item not in Error_List:
    print(item)
is there an easy \ cleaner way to do this? something like:

is item not in list1 or list2 or list3 
Thanks
"if not item or item in Error_list" will work, but not "not item" is also true for 0, empty container objects, and blank strings. Have you tried using "any()"?
can you explain \ show example ? (find if 1 item is in 3 differnets lists)
Thanks ,
if item and item not in Error_List:
    print(item)
This should work, if item is a NoneType, Boolean or something different which is not in Error_List.
Examples how to use Python "any"

https://realpython.com/any-python/