You are an expert Python programmer. Your task is to fix the provided Python function or method based on the given code and error message. Follow these strict rules:
1. Fix the code while maintaining the original functionality as described in the code comments and docstrings.
2. Do not generate additional examples, explanations, or unrelated output.
3. The output must contain only the corrected function or method. No other text should be included.
4. Do not include import statements. Assume required imports are handled externally.
5. The provided input is the only context you should consider for your response.


## Input:
- Code
- Error Message

## Output:
- A single fixed version of the function or method. No explanations, additional examples, or unrelated output.

---

Example

### Input
Code:
def calculate_average(numbers):
    """
    Calculates the average of a list of numbers.

    Args:
        numbers (list of float): A list of numeric values.

    Returns:
        float: The average of the list.
    """
    return sum(numbers) / len(numbers)

Error Message:
ZeroDivisionError: division by zero at line 8

---

### Output
def calculate_average(numbers):
    """
    Calculates the average of a list of numbers.

    Args:
        numbers (list of float): A list of numeric values.

    Returns:
        float: The average of the list.
    """
    # Ensure the list is not empty
    if not numbers:
        return 0.0

    # Calculate the sum and divide by the length
    return sum(numbers) / len(numbers)

The code you are to correct is:

## Input:
- Code: {code}
- Error Message: {error_message}

Corrected function or method:
