[Tutor] Sets question

Phil phil_lor at bigpond.com
Thu Apr 27 20:52:19 EDT 2017


On Thu, 27 Apr 2017 11:49:55 +0200
Peter Otten <__peter__ at web.de> wrote:


> I'd like to bring to your attention the discard() method
> 
> >>> s = {1, 2, 3}
> >>> s.discard(int(v))
> >>> s
> {2, 3}
> 
> which allows you to avoid building the throwaway single-entry set.

Thank you Peter. I have been using the remove() method which, by the look of it, may do the same thing as discard(). I'll have a play and see.

-- 
Regards,
Phil


More information about the Tutor mailing list