{"record":{"id":"7210dcc91bf33f67","repo":"TheAlgorithms/Python","slug":"missing-an-input","errorCode":null,"errorMessage":"Missing an input","messagePattern":"Missing an input","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"maths/manhattan_distance.py","lineNumber":78,"sourceCode":"    >>> _validate_point(\"not_a_list\")\n    Traceback (most recent call last):\n         ...\n    TypeError: Expected a list of numbers as input, found str\n    \"\"\"\n    if point:\n        if isinstance(point, list):\n            for item in point:\n                if not isinstance(item, (int, float)):\n                    msg = (\n                        \"Expected a list of numbers as input, found \"\n                        f\"{type(item).__name__}\"\n                    )\n                    raise TypeError(msg)\n        else:\n            msg = f\"Expected a list of numbers as input, found {type(point).__name__}\"\n            raise TypeError(msg)\n    else:\n        raise ValueError(\"Missing an input\")\n\n\ndef manhattan_distance_one_liner(point_a: list, point_b: list) -> float:\n    \"\"\"\n    Version with one liner\n\n    >>> manhattan_distance_one_liner([1,1], [2,2])\n    2.0\n    >>> manhattan_distance_one_liner([1.5,1.5], [2,2])\n    1.0\n    >>> manhattan_distance_one_liner([1.5,1.5], [2.5,2])\n    1.5\n    >>> manhattan_distance_one_liner([-3, -3, -3], [0, 0, 0])\n    9.0\n    >>> manhattan_distance_one_liner([1,1], None)\n    Traceback (most recent call last):\n         ...\n    ValueError: Missing an input","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/manhattan_distance.py#L60-L96","documentation":"Raised by _validate_point() in maths/manhattan_distance.py when the point is falsy — None, an empty list [], or an empty container. The `if point:` guard treats any empty input as a missing value and raises ValueError('Missing an input') before any dimension checks run.","triggerScenarios":"manhattan_distance([], [1,2]), manhattan_distance(None, [1,2]), or a point loaded from a row that was never populated (defaults to []).","commonSituations":"Empty vectors from filtered-out data, default-argument accumulation bugs where a list stays empty, or None leaking through optional fields.","solutions":["Ensure both points contain data before calling; skip or impute empty records upstream.","Default to a zero vector of the right dimension if an 'empty' point is semantically valid in your domain.","Check `if not point_a or not point_b: ...` in your own code to handle the case explicitly."],"exampleFix":"# before\nmanhattan_distance([], [1, 2])\n\n# after\nif point_a and point_b:\n    d = manhattan_distance(point_a, point_b)\nelse:\n    d = 0.0  # or skip the record","handlingStrategy":"validation","validationCode":"if not point_a or not point_b:\n    raise ValueError('both points are required')  # or skip/impute the record","typeGuard":"def is_non_empty_list(p) -> bool:\n    return isinstance(p, list) and len(p) > 0","tryCatchPattern":null,"preventionTips":["Filter out empty records before batch distance computations.","Never use [] as a default point value; require explicit data."],"tags":["math","valueerror","empty-input","distance-metrics"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}