Add a list of elements to a given set as per follows in Python

 Given:

sampleSet = {"Yellow", "Orange", "Black"}
sampleList = ["Blue", "Green", "Red"]
Code : 
sampleSet={"Yellow", "Orange", "Black"}
sampleList = ["Blue", "Green", "Red"]
sampleSet.update(sampleList)
#sampleSet.add(sampleList[0])
#sampleSet.add(sampleList[1])
#sampleSet.add(sampleList[2])
print(sampleSet)

Comments