Ad
  • Custom User Avatar

    Some predicates return non boolean values (like 0 and 1).
    In python "is" compares identities of two objects and == compares values.
    That means if your predicate returns 1 and you check it with: "1 is True" that will return false. because they have different object id's

    To avoid that you check by value with ==. because "1 == True" is True in python. they have the same value

    Even better is if you avoid the == check completely like this: if predicate(elem, i): ... that's just cleaner code though, its logically the same as if predicate(elem, i) == True ...

    If you still have questions, feel free to ask.