{"id":3538,"date":"2021-04-26T09:46:53","date_gmt":"2021-04-26T04:16:53","guid":{"rendered":"https:\/\/python-programs.com\/?p=3538"},"modified":"2021-11-22T18:43:05","modified_gmt":"2021-11-22T13:13:05","slug":"python-set-remove-vs-discard-vs-pop","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-set-remove-vs-discard-vs-pop\/","title":{"rendered":"Python Set: remove() vs discard() vs pop()"},"content":{"rendered":"

A Python set is a list of things that are not in any particular order. – element in the set must be unique and immutable, and duplicate elements are removed from the sets. Sets are mutable, which means we can change them after they’ve been formed.<\/p>\n

Unlike other Python sets, the elements of the set have no index, which means we can’t access any element of the set directly using the index. We may, however, print them all together or loop through the collection to get the list of elements.<\/p>\n

Example:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

givenset= <\/span>{<\/span>'This'<\/span>, <\/span>'is'<\/span>, <\/span>'BTechGeeks'<\/span>} element='is'\r\n<\/span><\/pre>\n

Output:<\/strong><\/p>\n

{'BTechGeeks', 'this'}<\/pre>\n

Remove a element from the Set<\/h2>\n

There are several ways to remove a element from the set some of them are:<\/p>\n