w3resource logo
Python Exercises

Python Exercise: Add member in a set

Python sets: Exercise-3 with Solution

Write a Python program to add member(s) in a set.

Sample Solution:-

Python Code:

#A new empty set
color_set = set()
color_set.add("Red")
print(color_set)
#Add multiple items
color_set.update(["Blue", "Green"])
print(color_set)

Sample Output:

{'Red'}                                                                                                       
{'Red', 'Blue', 'Green'}

Python Code Editor:

Improve this sample solution and post your code through Disqus