0
msg = ("HI")
print(msg)

Output in Terminal

PS C:\Users\Yumil\OneDrive\Desktop\Work\NewProjects> & C:/Users/Yumil/AppData/Local/Microsoft/WindowsApps/python3.10.exe
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print(msg)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'msg' is not defined
>>> & C:/Users/Yumil/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/Yumil/OneDrive/Desktop/Work/NewProjects/madlibs.py
  File "<stdin>", line 1
    & C:/Users/Yumil/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/Yumil/OneDrive/Desktop/Work/NewProjects/madlibs.py
    ^
SyntaxError: invalid syntax
>>>
0

1 Answer 1

0

You don't need to type anything in the terminal window.

Close it, and right click on the file/editor to run the complete code as a file.

Alternatively, type exit to get out of the Python REPL, then simply remove the starting & character from the command

Sign up to request clarification or add additional context in comments.

2 Comments

When I right click > Run Python file on terminal I get NameError and SyntaxError
The code you've posted has neither. The >>> means you are running a Python REPL. You need to type exit there. Then run only python3.10.exe madlibs.py at the PS C:/...> prompt, or use the run button - code.visualstudio.com/docs/python/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.