1. Problem to create a set in Python

In this Python set program, we will create a set in Python and add some elements in it as an example with the help of the below-given steps.

What is set?
Sets are used to store multiple items in a single variable.
The set is one of 4 built-in data types in Python used to store collections of data.
It is an unordered collection data type that is iterable, mutable, and has no duplicate elements.

Create a set in Python: 

Steps to solve the program
  1. Create a set using {}.
  2. Add some elements to the set.
  3. Print the set.
				
					a = {1,2,3,5,6}
print("Set: ",a)
				
			

Output :

				
					Set:  {1, 2, 3, 5, 6}
				
			

add an element to a set.

Leave a Comment