Home Blog Python Notes

Return multiple values from a function in Python Example

Published:


def f(in_str):
    out_str = in_str.upper()
    return True, out_str # Creates tuple automatically

succeeded, b = f("a") # Automatic tuple unpacking

print ("var1" , succeeded , " var2" , str(b))
Comment