Google News
logo
Python Program to Add an item to a set
To add an item to a set in Python, we can use the `add()` method. Here's an example program :
Program :
# create a set
my_set = {1, 2, 3}

# add an item to the set
my_set.add(4)

# print the updated set
print(my_set)
Output :
{1, 2, 3, 4}