close

[Solved] syntaxerror invalid token in python

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error syntaxerror invalid token in Python. So Here I am Explain to you all the possible solutions here.

Without Wasting your time, Lets start This Article to Solve This Error.

How To Solve syntaxerror invalid token in python Error ?

Question: How To Solve syntaxerror invalid token in python Error ?
Answer: This Error Solve syntaxerror invalid token in python occurs because leading zeros are not allowed on numbers 05,0123,etc are not allowed but should be written as 5 and 123 instead to solve this error I would suggest (similarly to the other answers) that you drop the leading zero ((2016,4,3)) or represent these using strings (("2016","04","03")).

Solution 1

This Error Solve syntaxerror invalid token in python occurs because leading zeros are not allowed on numbers 05,0123,etc are not allowed but should be written as 5 and 123 instead to solve this error I would suggest (similarly to the other answers) that you drop the leading zero ((2016,4,3)) or represent these using strings (("2016","04","03")).

Solution 2

The problem is the 0 before the 4. If you want to store that kind of infos, try using strings.

a = (2016,04,03) --> Error
a = (2016,4,3) --> No Error
a = ("2016","04","03") --> No Error
a = "2016-04-03" --> you could retrieve Year, Month and Day by splitting this string

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment