Skip to content

Chapter 5. Statistics, median function #123

@Zahed-Golabi

Description

@Zahed-Golabi

the median function raise "IndexError" while pass an empty list as an argument to function.

place this lines correct the issue:

elif n == 0:
return "The list is empty"

else:
    # if even, return the average of the middle values
    lo = midpoint - 1
    hi = midpoint
    return (sorted_v[lo] + sorted_v[hi]) / 2

Capture

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions