In python, I have a list that should have one and only one truthy value (that is, bool(value) is True). Is there a clever way to check for this
bool(value) is True
You can do:
x = [bool(i) for i in x] return x.count(True) == 1
Or
x = map(bool, x) return x.count(True) == 1
Building on @JoranBeasley's method:
sum(map(bool, x)) == 1