0

I have started learning today the python. And during my lecture on variables I found that whenever I try to assign a value starting with 0 it gives:

syntax error :Invalid token

Like

zip=01290
zip=01

but when I tried simple

zip=0

it does not give any error.

I guess I am writing the code right because I have checked the syntax on internet.

Is it a problem in python or something else?

Maroun
  • 94,125
  • 30
  • 188
  • 241
  • And there you have found another reason why you should only treat strings of digits as strings, not as numbers, unless you intend to do calculations with them. – Tim Pietzcker Apr 05 '13 at 20:04
  • why is it giving error?? – muhammad kamran Apr 05 '13 at 20:07
  • Did you read the linked question/answer? `01` used to mean "octal 1" in Python 2. That syntax is no longer valid in Python 3. – Tim Pietzcker Apr 05 '13 at 20:09
  • P.S.: You shouldn't use `zip` as a variable name. That's the name of a very handy [builtin](http://docs.python.org/3.3/library/functions.html#zip). – DSM Apr 05 '13 at 20:35
  • Start a literal number with a '0', it interprets it as an octal number and you can't have an '9' in an octal number. – skr Jun 13 '17 at 10:21

0 Answers0