# Set

> A group of values with no repeats. Each value is in it just once.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Hash Set

## Think of it like

Think of it like a sticker book. Each sticker goes in once, and a spare has no spot.

## Definition

A set is a collection where each value can appear only once. Add the same value twice and the set still holds one copy. Most sets keep no order, so there is no first or last item. Sets are quick at answering one question: is this value in here? They are handy for removing repeats from a list.

## Example

A blog has the tags red, blue and red on one post. Put in a set, the tags become just red and blue.

## Example code

```python
>>> tags = {"red", "blue", "red"}
>>> len(tags)
2
>>> "red" in tags
True
```

Red was added twice, but the set keeps one copy.

## Why it matters

Checking if something is in a set is much faster than searching a long list. It also clears out repeats for free.

## Common mistake

Expecting a set to keep its items in order. Use an array when the order matters.

## Three principles

- **No repeats.** Each value is kept only once.
- **No set order.** Items have no first or last.
- **Fast to check.** Is it in here? is answered at once.

## Related terms

- [Array](https://learn.benibix.com/term/development/array)
- [Dictionary](https://learn.benibix.com/term/development/dictionary)
- [Data Type](https://learn.benibix.com/term/development/data-type)
- [Boolean](https://learn.benibix.com/term/development/boolean)

## Told apart from

- [Dictionary vs Set](https://learn.benibix.com/compare/dictionary-vs-set): People think a set is just a dictionary with no values, because in Python both are written with curly brackets. A dictionary pairs each key with a value, so you look a value up by its key. A set holds single values, each one once, and has nothing to look up. In Python, {} on its own makes an empty dictionary. An empty set is written set().

## Taught in

- [Lists, Dictionaries and Sets](https://learn.benibix.com/learn/development-concepts/lists-dictionaries-and-sets): Programming Basics, 8/18

---

Source: https://learn.benibix.com/term/development/set
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
