Python/Invalid Syntax
Question:
I’m new to programming language and started learning python. While practicing writing code in VS code editor, I’m getting invalid syntax error for the following code:
sidekick = "WonderBoy"
print("You ruined the Grill Master's barbeque!")
print("The crowd is chanting your name!")
print(sidekick * 20)
But When I type the same code in python own shell editor, above code executes well. Could anyone tell me what’s wrong with the code.
Code Editor: Visual Studio Code
Error occurring instance: Right click and select “Run python file in terminal”
Error:
>SyntaxError: invalid syntax
>>> & C:/Users/abhis/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/abhis/Desktop/Ex_Files_Programming_Foundations_Fundamentals/Exercise Files/Chap02/text1.py"
File "<stdin>", line 1
& C:/Users/abhis/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/abhis/Desktop/Ex_Files_Programming_Foundations_Fundamentals/Exercise Files/Chap02/text1.py"
^
SyntaxError: invalid syntax
Answers:
“Looks like your problem is that you are trying to run python test.py from within the Python interpreter, which is why you’re seeing that traceback.
Make sure you’re out of the interpreter, then run the python test.py command from bash or command prompt or whatever.”
— syntax error when using command line in python
just enter “quit()” in terminal and try again
Languages are spoken differently as well as wrote differently. Learning to communicate can be complex for all individuals. Patience is always a virtue. Practice makes perfect sometimes. TRY
I’m new to programming language and started learning python. While practicing writing code in VS code editor, I’m getting invalid syntax error for the following code:
sidekick = "WonderBoy"
print("You ruined the Grill Master's barbeque!")
print("The crowd is chanting your name!")
print(sidekick * 20)
But When I type the same code in python own shell editor, above code executes well. Could anyone tell me what’s wrong with the code.
Code Editor: Visual Studio Code
Error occurring instance: Right click and select “Run python file in terminal”
Error:
>SyntaxError: invalid syntax
>>> & C:/Users/abhis/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/abhis/Desktop/Ex_Files_Programming_Foundations_Fundamentals/Exercise Files/Chap02/text1.py"
File "<stdin>", line 1
& C:/Users/abhis/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/abhis/Desktop/Ex_Files_Programming_Foundations_Fundamentals/Exercise Files/Chap02/text1.py"
^
SyntaxError: invalid syntax
“Looks like your problem is that you are trying to run python test.py from within the Python interpreter, which is why you’re seeing that traceback.
Make sure you’re out of the interpreter, then run the python test.py command from bash or command prompt or whatever.”
— syntax error when using command line in python
just enter “quit()” in terminal and try again
Languages are spoken differently as well as wrote differently. Learning to communicate can be complex for all individuals. Patience is always a virtue. Practice makes perfect sometimes. TRY