Why Can't I Store a Number Starting with 0?


Why can I not store a number starting with 0?

If I do:

1 todays_date = 06102018

I receive Syntax Error: invalid token

However, there will be no error if I start a number with a non-zero number. Why is this?

What can I store in a variable?

Hi @alamgirkzs,

It’s not possible to store an integer with a leading 0 in Python. Depending on what you want to do, you might be able to store it as a string instead, but the best thing is probably to just add the leading 0 when you print the variable, like this:

todays_date = 6102018



Most things you can possibly type are disallowed, or rather, lack meaning. The big question is what you were hoping to get out of it

In python2 it’s valid, but does something non-obvious.

DEC 25 == OCT 31

for curiosity sake.

Christmas and Hallowe’en on the same day seems a little weird.


This topic is solved.