How to check whether a global variable exists in Python

1 Answer

0 votes
s = "python"

if 's' in globals():
   print ("Variable exist")
else:
    print ("Variable not exist")
    
    
    
'''
run:

Variable exist

'''

 



answered Feb 22, 2021 by avibootz

Related questions

1 answer 167 views
3 answers 338 views
1 answer 156 views
2 answers 160 views
2 answers 191 views
3 answers 261 views
...