Just to clear a couple of things up before we close this thread…
In Python 2 (what these courses are based upon),
range() returns a list. Only Python 3 requires the list constructor since it returns an iterator, not a list.
What the OP (who is long gone, by the way) is (was) seeking was to do with equality, not whether the value is a boolean.
>>> def is_in_range(x):
return x in range(1, 5)
The return value will be a boolean.
Recall that while there are only two member tokens in the
bool class, there are infinitely many boolean expressions. We will want a function that can test them, as well.
>>> def is_boolean(x):
return isinstance(x, bool)
>>> is_boolean(7 > 6)
@rumbold, please do not resurrect moribund topics (anything older than a week), especially when we cannot know if the OP is actively engaged or not.