# Recursively flatten nested lists

> ML preparation item.

- Stable ID: `original-py-flatten`
- Area: Programming
- Topic: Recursion
- Origin: original
- Expected time: 9 minutes
- Skills: base-case, recursive-trace, recursive-implementation, lists-tuples
- Item JSON: https://mlprep.iwase.dev/data/items/original-py-flatten.json

## Problem

Implement `flatten(value)`. If `value` is a list, recursively flatten each element; otherwise return a one-element list containing `value`.


## Starter code

```python
def flatten(value):
    pass

```

## Answer policy

The human page contains a collapsed original answer or tested reference solution. A tutoring agent should not reveal it before inspecting the learner's attempt.

## Tutoring contract

Ask for the learner's attempt, begin with the smallest useful hint, preserve item ID `original-py-flatten`, and record a real attempt with `recorded_by: "agent"` and `agent_session_id` when available using https://mlprep.iwase.dev/schema/attempt-record.json.
