Design a logical expression equivalent to the following statement:
x
is a list of three or five elements, the second element of which is
You should compare the type of x
to the bool
class:
type(x) == bool
or:
type(x) == type(True)
Here is more on the type method
From Data model docs:
Booleans (bool)
These represent the truth values False and True. The two objects representing the values False and True are the only Boolean objects. The Boolean type is a subtype of the integer type, and Boolean values behave like the values 0 and 1, respectively, in almost all contexts, the exception being that when converted to a string, the strings "False" or "True" are returned, respectively.