Treat functions that return multiple values in Python [duplicate]

-1

For example, I have a mergeSort(alist) function that has return

return count, blist

that is, returns an integer that is the inversion counter and a list of values.

When you pass a list 5 4 3 1 2 5 and make print(mergeSort(lista)) , it is printed

(5, ['1', '2', '3', '4', '5']) .

How to get only the integer ( 5 ) of the counter?

    
asked by anonymous 29.09.2018 / 20:44

1 answer

0

As I wrote the question, something very simple occurred to me, I tried it and it worked so I decided to continue the question and leave the answer in case anyone has the same doubt.

Considering the example, just do

x, y = mergeSort(entrada)
    print(x)

And so the x receives the first return and the y the second, being that they can be more variable according to the amount of returns of the function.

    
29.09.2018 / 20:44