Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

How do I check if a variable exists?

Asked by Anusha Acharya Apr 7, 2021 460 views 1 answer
Share

About this question

 I want to check if a variable exists. Now I'm doing something like this:

try:

   yourVar

except NameError:

   # Do something.

Are there other ways without exceptions?

Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.