fork download
  1. def is_non_empty_array(variable):
  2. # Check if the variable is not None and is a list with at least one element
  3. return variable is not None and isinstance(variable, list) and len(variable) > 0
  4.  
  5. # Example usage:
  6. variable1 = [1, 2, 3]
  7. variable2 = []
  8. variable3 = None
  9.  
  10. print(is_non_empty_array(variable1)) # Output: True
  11. print(is_non_empty_array(variable2)) # Output: False
  12. print(is_non_empty_array(variable3)) # Output: False
Success #stdin #stdout 0.01s 7180KB
stdin
Standard input is empty
stdout
True
False
False