I get a syntax error about File "<stdin>", line 1
Question:
This is the error, I have no idea where the fault is:
> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe
"c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
File "<stdin>", line 1
& C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
^
SyntaxError: invalid syntax
Answers:
You’re getting a Python SyntaxError
because you are trying to run a PowerShell command in the Python shell:
>>> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
exit
out of that shell and then run your PowerShell command in PowerShell. The prompt should look something like
PS C:>
The Python shell is for running code interactively, e.g. you could type something like import pygame
or print("Hello, world!")
directly into it.
To solve this error, just write this command in your terminal :
>>> exit()
This is the error, I have no idea where the fault is:
> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe
"c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
File "<stdin>", line 1
& C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
^
SyntaxError: invalid syntax
You’re getting a Python SyntaxError
because you are trying to run a PowerShell command in the Python shell:
>>> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
exit
out of that shell and then run your PowerShell command in PowerShell. The prompt should look something like
PS C:>
The Python shell is for running code interactively, e.g. you could type something like import pygame
or print("Hello, world!")
directly into it.
To solve this error, just write this command in your terminal :
>>> exit()