How to create a set in Python?

  • Set is a data type used to store a group of data and hold several objects in a single variable.
  • Sets are written in curly brackets

Example:

thisset = {"red", "blue", "green"}
print(thisset)

Output

set bi

Set items are:

  • Unordered: The order of the items in a set is not specified.
  • Unchangeable: Set items cannot be changed once created.
  • Unrepeatable: Set does not allow two items with the same value.