'Multiple conditions if least minimum are met then print PYTHON

-need your help, I have 10 conditions where if any 5 conditions are true then function will -shortlist those 5 and from that if any 3 conditions are true then function will validate:

con1 = check(df)
con2 = check2(df)
con3 = check3(df)
con4 = check4(df)
con5 = check5(df)
if ([con1 or con2 or con3 or con4 or con5]) == True:
    then check if atleast 3 conditions are True: 
       if true:
           print(df)


Solution 1:[1]

For checking whether at least 3 conditions are true, you can do:

if sum([cond1, cond2, cond3, cond4, cond5]) >= 3:

The sum() function will treat True as 1 and False as 0.

This assumes that all of the conditions are boolean values. See the comments for handling things like None.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1