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 165 views
3 answers 331 views
1 answer 153 views
2 answers 155 views
2 answers 185 views
3 answers 258 views
...