[Python] max() output depends on order when nan is present [duplicate]

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I am puzzled by this behaviour of Python's max() function:

    >>> a = 100
    >>> n = float("nan")
    >>> a
    100
    >>> n
    nan
    >>> max(a, n)
    100
    >>> max(n, a)
    nan


    That is the ORDER of the parameters determines the outcome?

    Continue reading...

Compartilhe esta Página