---
title: "random.choice"
space: "Student Handbook"
url: "https://portal.cs17.org/student-handbook/python-manual/random/choice"
updated: "2026-10-05"
---

Picks a random item from a list or a string.

## Synopsis

```python
import random
random.choice(items)
```

## Description

Every item has the same chance of being picked.

## Parameters

| Name | Meaning |
| --- | --- |
| `items` | A list, or a string to pick one character from. |

## Return value

One item.

## Example

```python
import random

colours = ["red", "green", "blue"]
print(random.choice(colours))
print(random.choice("HT"))
```

It prints something like this. Your values will differ: they are random.

```text
blue
T
```

## Common mistake

```python
import random

print(random.choice([]))
```

Python stops with:

```text
IndexError: Cannot choose from an empty sequence
```

An empty list has nothing to pick from.

## See also

[random.randint](/student-handbook/python-manual/random/randint), [Indexing and slicing](/student-handbook/python-manual/lists/indexing-and-slicing)

[random.choice in the Python documentation](https://docs.python.org/3/library/random.html#random.choice)
