On Sat, 16 Sep 2017 01:43 am, Ganesh Pal wrote:

> I have a function that return's x  variables  How do I check if all the the
> values returned  are not None/False/0/''
[...]
> value1, value2 , value3 = return_x_values()
> 
> 
> # check if its not none
> 
> # I think this can be better
> if value1 and value2 and value3 :
>    print "continue with the program"


values = return_x_values()
if all(values):
    print "continue"
else:
    print "at least one value was falsey"


If you want to test for None specifically:

if any(v is None for v in values):
    print "at least one value was None"





-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to