0

How come max([1,2,3], [1,1,4]) returns [1,2,3] not [1,1,4]?

I was asked this question in a class. I don't understand why it returns [1,2,3] and the logic behind it (even if it returns [1,1,4], I still don't understand what max() function does).

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
toto.
  • 1

1 Answers1

0

The function max will succeed in outputing a maximum as long as the provided arguments are comparable.

In this case, the first argument is greater than the second with regard to list-ordering.

>>> [1, 2, 3] > [1, 1, 4]
True
Olivier Melançon
  • 21,584
  • 4
  • 41
  • 73