python-3.xvisual-studio-codeidepython-idlecoderunner

VS code for Python does not show the contents of the variable after the codes are executed


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.


Solution

  • 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