> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# lcpy gen Error: Problem Already Exists

> lcpy refuses to generate into a directory that already exists. Pick another output directory or pass --force to overwrite.

```
Error: Problem 'two_sum' already exists. Use --force to overwrite.
```

`lcpy gen` never overwrites silently. A directory named after the problem
already exists under the output directory, so generation stops.

## Reproduce

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lcpy gen -n 1
lcpy gen -n 1
# Error: Problem 'two_sum' already exists. Use --force to overwrite.
```

## Fix

* **Generate somewhere else**: pass a different output directory,
  `lcpy gen -n 1 -o practice/week-1`.
* **Regenerate on purpose**: add `--force`. The generated files replace
  whatever is there, including your edits. If the directory holds a
  solution you want, copy `solution.py` out first, regenerate, then copy
  it back.

Not this error? Every fix lives on
[Troubleshooting](/troubleshooting).
