lundi 23 octobre 2017

IF statement with 2 variables and 4 conditions

I have 2 variables, say x and y, I need to check which of them is null.

if x is None and y is None:
    # code here
else:
    if x is not None and y is not None:
        # code here
    else:
        if x is None:
            # code here
        if y is None:
            # code here

Is there better approach to do this.I am looking for a shorter IF ELSE structure.

Aucun commentaire:

Enregistrer un commentaire