Check if object is a number or boolean

后端 未结 7 1049
攒了一身酷
攒了一身酷 2021-02-06 20:42

Design a logical expression equivalent to the following statement:

x is a list of three or five elements, the second element of which is

7条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 21:26

    I follow the recent answer who tell to use type and it seems to be the incorrect way according to pylint validation:

    I got the message:

    C0123: Using type() instead of isinstance() for a typecheck. (unidiomatic-typecheck)

    Even if it's an old answer, the correct one is the accepted answer of @Lev Levitsky:

    isinstance(x[0], (int, float))
    

提交回复
热议问题