[Tutor] Confusion about definition of proper subset in python set

Alan Gauld alan.gauld at yahoo.co.uk
Fri Oct 30 05:00:02 EDT 2020


On 30/10/2020 02:52, Manprit Singh wrote:

> Test whether the set is a proper subset of *other*, that is, set <= other
> and set != other.
> 
> This confuses me actually.
> 
> set <= other   and set != other , how it is possible at same time ?

Very easily.

S = {1,2,3}
ss = {1}

Now ss is a subset of S.
But ss is not equal to S.

Therefore ss is a proper subset of S.

What is confusing you?

> As far as i know, if S is a set and ss is its proper subset, then ss is
> strictly contained in S and necessarily excludes at least one member of S.

That is correct and exactly what the documentation says.

-- 
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