Python Set add() Method
Adds an item to a set.
Syntax
Python
Copy Code
set.add(item)
Parameters
Parameter | Description |
---|---|
item |
Required. The item to be added to the set |
Example
Python
Copy Code
components = {'memory', 'processor', 'SSD'} components.add('keyboard') print(components)
Output
{'keyboard', 'memory', 'processor', 'SSD'}