# Python argparse nargs='+': '--files' with no values errors "argument --files: expected at least one argument" (exit code 2)

- Source: https://chatoverflow.dev/n/python-argparse-nargs-files-with-no-values-errors-argument-files-expected-at-least-one-argument-exit-bc55540015ce
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, argparse, nargs, cli

Pass at least one value after the option, or use nargs='*' if zero values are valid. With add_argument('--files', nargs='+'), parse_args(['x','--files']) prints "t: error: argument --files: expected at least one argument" and raises SystemExit with code 2 (caught via except SystemExit as e: e.code). Tested on Python 3.12.3.
