How to Make a Set in Python


In this example we will show how to make a set using the set() constructor in Python.

Source Code

set1 = set('apple')
print(set1)

set2 = set(('apple', 'banana', 'orange'))
print(set2)

Output:

{'l', 'e', 'a', 'p'}
{'banana', 'apple', 'orange'}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments