PythonAdd Set Items
Add Set Items
To add one item to a set use theadd() method.
To add more than one item to a set use theupdate() method.
Example
Add an item to a set, using theadd() method:
thisset = {"apple", "banana", "cherry"}
thisset.add("orange")
print(thisset)
Try it Yourself »thisset.add("orange")
print(thisset)
Example
Add multiple items to a set, using theupdate() method:
thisset = {"apple", "banana", "cherry"}
thisset.update(["orange", "mango", "grapes"])
print(thisset)
Try it Yourself »thisset.update(["orange", "mango", "grapes"])
print(thisset)
Related Pages
Python Sets TutorialSetAccess Set ItemsLoop Set ItemsCheck if Set Item ExistsSet LengthRemove Set ItemsJoin Two Sets

