13.6 Set Methods
Python has a set of built-in methods that you can use on sets. Example Add an element to the fruits set:fruits = {“apple”, “banana”, “cherry”}fruits.add(“orange”)print(fruits) Output:{‘orange’, ‘banana’, ‘cherry’, ‘apple’} Method Syntax Description add() set.add(elmnt) Adds an element to the set clear() set.clear() Removes all the elements from the set copy() set.copy() Returns a copy of the set difference() set.difference(set) Returns… Read More »
