def validate_lists(list_of_lists):
"""
Validates a list of lists for consistency and errors.
"""
if not isinstance(list_of_lists, list):
return "Error: Input must be a list."
if not list_of_lists:
return "Warning: Input list is empty."
first_list_len = len(list_of_lists[0])
for lst in list_of_lists:
if not isinstance(lst, list):
return "Error: All elements of the input list must be lists."
if len(lst) != first_list_len:
return f"Error: List lengths are inconsistent. Expected {first_list_len}, got {len(lst)}."
for item in lst:
if not isinstance(item, (int, float, str, bool, type(None))): #Allow common types
return f"Error: List elements must be of type {type(lst[0]) if lst else 'any'}"
return "Lists are valid."
Add your comment