Invalid Token in Python

0 votes
This example is from Project Euler's problem number 11. The one with the grid.

I'm trying to replicate the grid in a large multidimensional array, But it's giving me a syntax error and i'm not sure why

grid = [
[ 08, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50, 77, 91, 08 ],
[ 49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 04, 56, 62, 00 ],
[ 81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 03, 49, 13, 36, 65 ],
...
And I get this error:

  File "D:\development\Python\ProjectEuler\p11.py", line 3
    [ 08, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50, 77, 91 , 08 ],
       ^ SyntaxError: invalid token
 

Can anyone help me with this? Why is it throwing an error before the comma?
Apr 26, 2019 in Python by ana1504.k
• 7,910 points
6,813 views

2 answers to this question.

0 votes
I think when you start a literal number with a 0, it interprets it as an octal number and you can't have an '8' in an octal number.
answered Apr 26, 2019 by SDeb
• 13,300 points
0 votes
in python version 2.7,3.6.8 you can't write 0 before any number like you  wrote 08,02 .
answered Jun 25, 2020 by ker

Related Questions In Python

+1 vote
10 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

The following are totally acceptable in python: passing ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,560 points
406,523 views
+4 votes
4 answers
0 votes
1 answer

invalid literal for int() with base 10 in python

Hello, You can try this simple code: def getSum(n): ...READ MORE

answered Nov 23, 2020 in Python by Niroj
• 82,880 points
1,863 views
+3 votes
7 answers

How can I rename a file in Python?

yes, you can use "os.rename" for that. ...READ MORE

answered Mar 31, 2018 in Python by DareDev
• 6,890 points
19,350 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,058 views
0 votes
1 answer
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,300 points
2,094 views
0 votes
1 answer

Print C format in Python

For printf- style formatting and special case ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,300 points
795 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP