Course Content
Basic i/o operations
Object Oriented Programming
0/2
Inheritance
0/1
Modules
0/1
Packages
0/1
Exception Handling
0/1
Python Programming

The set data structure of Python is a list of data elements stored in unordered or no index manner. Set is created using pair of curly braces.

#Example code to create a Set
fruits = {“apple”, “banana”, “cherry”}
print(fruits)

Access Items
Since set is not maintain any index, we cannot access elements of set using index values. But we can search for the presence of a data element by its value.

#Check if “banana” is present in the set:
fruits = {“apple”, “banana”, “cherry”}
print(“banana” in fruits)

You cannot copy content of this page