Answers for "python check variable ex"

11

how to check if a variable exists in python

#if the variable is local: 
if 'myVar' in locals():
  # myVar exists

#if the variable is global:
if 'myVar' in globals():
  # myVar exists.
Posted by: Guest on October-03-2020
0

how to check if variable in python is of what kind

kind = "World"
print(type(kind))
kind2 = 0876
print(type(kind2))
Posted by: Guest on September-24-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language