[Tutor] consider a problem of finding if two lists have any item in common
Peter Otten
__peter__ at web.de
Sun Mar 21 10:53:02 EDT 2021
On 21/03/2021 09:52, Alan Gauld via Tutor wrote:
> On 21/03/2021 07:15, Manprit Singh wrote:
>
>> lst1 = [2, 4, 6, 9]
>> lst2 = [2, 5, 9, 0]
>> this can be done using isdisjoint(other), it will return True if the lists
>> have no items in common .The official documentation says nothing about
>> other , just need to know if other can be an iterable or it should strictly
>> be a set or frozenset?
>> what should be the correct way ?
>
> Don't ask us, ask the interpreter, it knows best.
> And it gives faster answers too.
>
> If its answers aren't what you'd expect *then* ask us why?
While I tend to regard the interpreter's "answer" as authoritative there
is always a small chance that you rely on an implementation accident or
even a bug.
After a quick look into the documentation my impression is that for most
(all other?) set methods an iterable instead of a set is explicitly
allowed.
Therefore I'd expect that a documentation bug report would be welcome.
More information about the Tutor
mailing list