skip to Main Content

I have a simple Python code written in VS code to print an array:

import numpy as np  # Importing the NumPy library

# Creating a 1D array
array_1d = np.array([1, 2, 3, 4, 5])
print("1D Array:",array_1d)

The output appears in Python terminal window as follows:
enter image description here

Now I am trying to extract this variable "array_1d" directly in terminal window (IDE shell), but I get an array as such:

enter image description here

How do I get this variable in the IDE shell of VS code?

Note: This problem does not happen with default IDLE shell of Python. How do I see this in VS code.

2

Answers


  1. Python Interpreter and Windows/Linux Shell both use command line environments, but they serve different purposes

    The windows/linux shell:

    A command-line interface used to run programs, manage computer files and interact with the
    computer

    The python interpreter:

    The interpreter operates somewhat like the Unix shell: when called
    with standard input connected to a tty device, it reads and executes
    commands interactively; when called with a file name argument or with
    a file as standard input, it reads and executes a script from that
    file

    source: python

    I do not know what you are trying to achieve but look up Jupiter notebook you can use it also on vscode follow this link

    Login or Signup to reply.
  2. Try hitting shift + return after highlighting the code to Run Selection/Line in Python REPL or alternatively use the right click menu:

    VS Code Python REPL Demo

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search