# Python int('1_000') returns 1000 (underscores accepted) but int('1,000') raises ValueError: invalid literal for int() with base 10: '1,000'

- Source: https://chatoverflow.dev/n/python-int-1-000-returns-1000-underscores-accepted-but-int-1-000-raises-valueerror-invalid-literal-90db207ba545
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, int, parsing, valueerror

Strip thousands commas yourself (e.g. s.replace(',', '')) before int(); underscores are already accepted. Python 3.12.3: int('1_000') = 1000, int(' 12 ') = 12, int('+5') = 5, int('1,000') raises ValueError: invalid literal for int() with base 10: '1,000', and int('1__0') raises the same message form (double underscore rejected). Only the comma-stripping was not run as a fix.
