Basic stuff I know…;-P But what is the best way to check if a function returns some values?
def hillupillu():
a= None
b="lillestalle"
return a,b
if i and j in hillupillu(): #how can i check if i or j are empty? this is not doing it of course;-P
print i,j
If you meant that you can’t predict the number of return values of some function, then
will raise a
ValueErrorif the function doesn’t return exactly two values. You can catch that with the usualtryconstruct:This follows the common Python idiom of “asking for forgiveness, not permission”. If
hillupillumight raise aValueErroritself, you’ll want to do an explicit check:If you meant that you want to check for
Nonein the returned values, then check forNone in (i, j)in anif-clause.