Utilizor
Contact Us

Python Sets

Unordered, unindexed collection.

Examples

Create Set

Note: the order changes each time.

thisset = {"apple", "banana", "cherry"}
print(thisset)

Add Items

Adding an item.

thisset = {"apple", "banana", "cherry"}
thisset.add("orange")
print(thisset)

No Duplicates

Duplicate 'apple' is ignored.

thisset = {"apple", "banana", "cherry", "apple"}
print(thisset)

Test Your Knowledge

Python Quiz

No quiz available for this topic yet.