[Tutor] consider a problem of finding if two lists have any item in common

Alan Gauld alan.gauld at yahoo.co.uk
Sun Mar 21 04:52:53 EDT 2021


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?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list