Search code examples
pythonpython-3.xfunctionreturn

How to assign particular return variable in function on if/else statement in python


I have two functions as below:

def abc():
    i = "False"
    j = "100"
    return i,j

def xyz():
    if abc() == "False":  #I want to compare "False" with variable "i"
       print("Not Done")
    else:
        abc() == "101"    ##I want to compare "False" with variable "j"
        print("something else:")
xyz()

Current Output:

something else:

Expected Output:

Not Done

I want to know how to check particular return variable for particular if/else statement.


Solution

  • Simply this?

    def xyz():
        i, j = abc()
        if i == "False":
            print("Not Done")
        elif j == "101":
            print("something else:")