RUPAK22
RUPAK22

Reputation: 11

Returning multiple different values

How do I get both values while compiling? It is only returning 129.

def nestedListSum(NL):
    if isinstance(NL, int):
        return NL

    o=NL*2
    return o
    # some examples
print(nestedListSum(129))

Upvotes: 0

Views: 33

Answers (1)

Yu Hao
Yu Hao

Reputation: 122373

Put all values that you want to return in a single return statement:

def nestedListSum(NL):
    if isinstance(NL, int):
        o = NL * 2
        return NL, o
print(nestedListSum(129))

This returns a tuple (129, 258).

Upvotes: 2

Related Questions