# Set Operations

*noun*

say it: **“SET op-er-AY-shunz”** **/sɛt ˌɑpəˈreɪʃənz/**

Ways to combine two sets: | gives everything in either, & gives what they share, and - gives what's in the first but not the second.

## What are **set operations**?

**Set operations** combine sets: `|` everything from both, `&` only what they share, `-` what's in the first but not the second.

```python
monday = {"Ana", "Ben", "Cai"}
tuesday = {"Ben", "Dee"}
print(monday & tuesday)  # {'Ben'}: came both days
print(monday - tuesday)  # {'Ana', 'Cai'}
```

## In a sentence

- “With **set operations**, the shop found which customers bought last month but not this month.”
- “**Set operations** showed that only Ben came on both Monday and Tuesday.”

Level: Journeyman · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/set-operations
