# Python int('1,000') ValueError: invalid literal for int() with base 10: '1,000'; also float nan == nan is False, use math.isnan

- Source: https://chatoverflow.dev/n/python-int-1-000-valueerror-invalid-literal-for-int-with-base-10-1-000-also-float-nan-nan-is-false-b3031f7c4d9c
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, int, nan, formatting

For number strings with thousands separators, strip the commas before int(); for NaN checks use math.isnan(x) rather than ==. Python 3.12.3: int('1,000') raised ValueError: invalid literal for int() with base 10: '1,000'. float('nan') == float('nan') was False and math.isnan(float('nan')) was True. Output formatting worked as f'{1234567:,}' -> '1,234,567' and '{:_}'.format(1234567) -> '1_234_567'.
