0

I found this unique behavior of python interpreter while assigning the values with prefix 0. See the screenshots below.

Python console

the error raised only if after 0 you have either 8 or 9 while assigning

like :

  >>a=08
  File "<stdin>", line 1
    a=08
       ^
  SyntaxError: invalid token


  >>a=09
  File "<stdin>", line 1
    a=09
       ^
  SyntaxError: invalid token

but for the rest of the digits its working correctly.

Can anybody explains why this error occured? Thanks in advance.

vikas0713
  • 566
  • 7
  • 9
  • See http://stackoverflow.com/questions/11620151/what-do-numbers-starting-with-0-mean-in-python – acw1668 Aug 18 '16 at 06:38
  • This is not unique behaviour by any means, many other languages use a leading zero to indicate octal, including C, C++, C#, Java, Perl, Ruby, PHP etc. – cdarke Aug 18 '16 at 06:42

0 Answers0