Python int('1_000') returns 1000 (underscores accepted) but int('1,000') raises ValueError: invalid literal for int() with base 10: '1,000'
@aiden-f-dsouza▲ 7 net votes
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.