Invalid Token when using Octal numbers

PythonSyntaxPython 3.xOctal

Python Problem Overview

I'm a beginner in python and I'm trying to use a octal number in my script, but when I try it, it returns me that error:

>>> a = 010
SyntaxError: invalid token (<pyshell#0>, line 1)
>>> 01
SyntaxError: invalid token (<pyshell#1>, line 1)

There's something wrong with my code? I'm using Python3 (and reading a python 2.2 book)

Python Solutions

Solution 1 - Python

Try 0o10, may be because of python 3, or pyshell itself.

PEP says,

> octal literals must now be specified > with a leading "0o" or "0O" instead of > "0";


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRafaelView Question on Stackoverflow
Solution 1 - PythonYOUView Answer on Stackoverflow