{"id":23994,"date":"2021-10-14T09:13:42","date_gmt":"2021-10-14T03:43:42","guid":{"rendered":"https:\/\/python-programs.com\/?p=23994"},"modified":"2021-11-05T16:48:59","modified_gmt":"2021-11-05T11:18:59","slug":"python-program-for-set-remove-method","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-set-remove-method\/","title":{"rendered":"Python Program for Set remove() Method"},"content":{"rendered":"

In the previous article, we have discussed Python Program for Set min() Method<\/a>
\nPython set:<\/strong><\/p>\n

Python set is a list of items that are not ordered. \u2013 Each element in the set must be unique and immutable, and duplicate elements are removed from the sets. Sets are mutable, which means they can be changed after they have been created.<\/p>\n

The elements of the set, unlike other Python sets, do not have an index, which means we cannot access any element of the set directly using the index. To get the list of elements, we can either print them all at once or loop them through the collection.<\/p>\n

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

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

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

Given set = {'hello', 'this', 'is', 'btechgeeks'}\r\nitem to be removed = 'hello'<\/pre>\n

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

The given set is :\r\n{'hello', 'btechgeeks', 'is', 'this'}\r\nThe given set after removing the given specific item :\r\n{'btechgeeks', 'is', 'this'}<\/pre>\n

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

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

Given set = {10, 30, 50, 20, 30, 40, 60}\r\nitem to be removed = 10<\/pre>\n

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

The given set is :\r\n{40, 10, 50, 20, 60, 30}\r\nThe given set after removing the given specific item :\r\n{40, 50, 20, 60, 30}<\/pre>\n

Program for Set remove() Method in Python<\/h2>\n