Skip to content Skip to sidebar Skip to footer

Get Rid Of Syntaxerror: Invalid Syntax In Python

def success(self, input1: str = '', input2: str = '', input3: str = '') -> None: E ^ E SyntaxError: invalid syntax No idea what is happening her

Solution 1:

Since you're on Python 2.7, you need to back up to that syntax. Type hints are Python 3; remove them.

defsuccess(self, input1="", input2="", input3=""):

Solution 2:

The function you posted is valid Python 3.7. Type hints were added to Python in version 3.5.0, the code you posted should work in any version from 3.5.0 onwards:

Python 3.7.0 (default, Aug 22 2018, 20:50:05) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>defsuccess(self, input1: str = "", input2: str = "", input3: str = "") -> None:...        input1 = str(input1)...        input2 = str(input2)...        input3 = str(input3)...print(Color.BOLD + Color.GREEN + " " + Color.CHECKMARK + " " + input1 + 
Color.END + " " + input2 + " " + input3)
...>>>success
<function success at 0x7fb70e4c61e0>

I suspect you are using an older python version that does not support these language features.

Post a Comment for "Get Rid Of Syntaxerror: Invalid Syntax In Python"