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

Breaks a string into a list of parts.

## Synopsis

```python
text.split()
text.split(separator)
```

## Description

Without a separator, `split` breaks the string at spaces and drops the spaces.

## Parameters

| Name | Meaning |
| --- | --- |
| `separator` | The text to split at. Optional. The default is any whitespace. |

## Return value

A `list` of strings.

## Example

```python
print("hello big world".split())
print("2026-10-05".split("-"))
first, last = input("Full name: ").split()
print(last)
```

It prints:

```text
['hello', 'big', 'world']
['2026', '10', '05']
Full name: Ada Lovelace
Lovelace
```

## Common mistake

```python
first, last = input("Full name: ").split()
```

Python stops with:

```text
Full name: Ada
ValueError: not enough values to unpack (expected 2, got 1)
```

One word gives a list of one part, but the line asks for two. Check `len(...)` before unpacking.

## See also

[str.join](/student-handbook/python-manual/strings/join), [str.strip](/student-handbook/python-manual/strings/strip), [len](/student-handbook/python-manual/built-in-functions/len)

[str.split in the Python documentation](https://docs.python.org/3/library/stdtypes.html#str.split)
