Corbin P. answered 08/22/20
Tutor
5
(9)
High School/College Tutor Specializing in Computer Programming
You can use "locals()" and "globals()" to check if a variable exists locally or globally. For example:
if 'myVar' in locals():
# myVar exists locally
It's the same format for "globals()"