Search code examples
pythonvscode-python

When I use "def" function in my vscode(python) It's returning "syntax error"


I was trying to run the def command in my "vscode" but it keeps reporting a strange error that I don't understand and needs some help with. I am showing here a simple example of what is happening.

def hello_function():
    print("yeet")

hello_function()     

After running the def command I am always greeted with this ERROR:

enter image description here

Here's the full screenshot:

enter image description here

here's the python.python.path

enter image description here


Solution

  • You should be careful with spaces, Python is a case sensitive programming language.

    UPDATE


    • As, I saw the image I understood that the issue was not with spaces, but with the file itself. So, before running the code, SAVE the file and then run it.
    • You should add Python to the Path environment variable. Hope this guide helps. Then copy the PATH to VS Code