[Python] Python: check for data type in list

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    Is there a way to check if an instance of a specific data type is present in a list / dictionary, without explicitly checking every element / key?

    I suspect the answer is no. If it does exist, though, I imagine it would be similar to the way you can use the in operator to search for specific elements / keys, like this:

    3 in [1, 2, 3] # => True


    except you'd be checking for an instance of a data type rather than a some specific value, like this:

    int in [1,"a", 3.4] # => True


    Any ideas?

    Continue reading...

Compartilhe esta Página