Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding "invalid decimal literal"

Tags:

python

100_year = date.today().year - age + 100
      ^
SyntaxError: invalid decimal literal

I'm trying to understand what the problem is.

like image 966
lachimba Avatar asked Feb 01 '26 20:02

lachimba


1 Answers

Python identifiers can not start with a number.

The 'arrow' points to year because underscore is a valid thousands separator in Python >= 3.6, so 100_000 is a valid integer literal.

like image 164
DeepSpace Avatar answered Feb 04 '26 09:02

DeepSpace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!