What is a Set data type good for in Python?

Experience Level: Junior
Tags: Python

Answer

Sets are used to store multiple items in a single variable. The item value cannot be changed, but you an add and remove items to/from the set.

The set does not accept multiple items with the same value.

Example:

my_set = {"red", "amber", "green"}
print(my_set)

Python for beginners
Python for beginners

Are you learning Python ? Try our test we designed to help you progress faster.

Test yourself