# Enumeration (Enum)

> A type with a short, fixed list of named choices, like RED, AMBER and GREEN.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Enum, Enumerated Type, Enums

## Think of it like

It is like a menu with only three drinks. You must pick one of those, nothing else.

## Definition

An enum is a type with a fixed list of named choices. A traffic light could be RED, AMBER or GREEN, and nothing else. Code uses the names instead of loose words or numbers. Then the computer can catch a typo, like GRENE, before the code runs. Most languages have enums, including Java, C#, TypeScript and Python.

## Example

Emma's order app has an enum with PAID, SHIPPED and DELIVERED. An order can only ever be one of the three.

## Example code

```python
from enum import Enum

class Light(Enum):
    RED = 1
    AMBER = 2
    GREEN = 3

print(Light.GREEN.name)
# GREEN
```

Three named choices, and nothing else is allowed.

## Why it matters

Loose text like "shipped" and "Shipped" can slip through as two values. An enum allows exactly one spelling.

## Common mistake

Using plain numbers like 1, 2 and 3 for states. Months later, nobody remembers which number means what.

## Three principles

- **Fixed choices.** Only the listed names are allowed.
- **Names, not numbers.** The code says what it means.
- **Typos caught.** A wrong name is an error.

## Related terms

- [Data Type](https://learn.benibix.com/term/development/data-type)
- [Constant](https://learn.benibix.com/term/development/constant)
- [Switch Statement](https://learn.benibix.com/term/development/switch-statement)
- [Hard-Coding](https://learn.benibix.com/term/development/hard-coding)
- [Union Type](https://learn.benibix.com/term/development/union-type)

## Taught in

- [Type Conversion and Strings](https://learn.benibix.com/learn/development-concepts/type-conversion-and-strings): Programming Basics, 7/18

![Six small cards in two rows. Type conversion turns the text 42 into the number 42. Concatenation joins Hello and Emma. A tuple holds three values in fixed slots. An enum lists RED, AMBER and GREEN. A built-in function len counts five letters in hello. A hard-coded line has a tax rate of 0.2 written straight into the sum.](https://learn.benibix.com/diagrams/dev7-working-with-values.svg)

---

Source: https://learn.benibix.com/term/development/enum
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-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
