Compruebe si la cadena está vacía Python
my_str = ""
if not my_str:
print("empty")
else:
print("not empty")
#output: empty
Doubtful Dingo
my_str = ""
if not my_str:
print("empty")
else:
print("not empty")
#output: empty
#check is not null
if var is not None:
print('Var is not null')
variable = None
variable_2 = ''
variable_3 = 'string'
variable_4 = 5
def none_or_empty(variable):
return True if not variable else False
none_or_empty(variable)
none_or_empty(variable_2)
none_or_empty(variable_3)
none_or_empty(variable_4)