Find how many user variables are created in the current session in Python?

To find what all variables you have created so far in the session you can use the “dir()” command .

Sample Output in the command prompt:

How to list how many user variables are created in the current session in Python in Command Prompt?


Jupyter Notebook

The dir() command will work in Jupyter notebook as well. However, there is a magic command also in Jupyter its called “%whos“. You can use it to list all the user variables in python’s current session.

Sample output in Jupyter notebook

Python-How to list how many user variables are created in the current session in Python Jupyter Notebook

Author Details
Lead Data Scientist
Farukh is an innovator in solving industry problems using Artificial intelligence. His expertise is backed with 10 years of industry experience. Being a senior data scientist he is responsible for designing the AI/ML solution to provide maximum gains for the clients. As a thought leader, his focus is on solving the key business problems of the CPG Industry. He has worked across different domains like Telecom, Insurance, and Logistics. He has worked with global tech leaders including Infosys, IBM, and Persistent systems. His passion to teach inspired him to create this website!

Leave a Reply!

Your email address will not be published. Required fields are marked *