median of a list wehn every list element is 0 in python

If every list element is 0, then the median of the list will be 0. Here is the Python code to find the median of a list when every element is 0.

main.py
from statistics import median

# Create a list of zeros.
zeros_list = [0] * length_of_list

# Find the median of the zeros list.
median_of_zeros_list = median(zeros_list)

print("Median of zeros list is:", median_of_zeros_list)
228 chars
10 lines

Output:

main.py
Median of zeros list is: 0
27 chars
2 lines

related categories

gistlibby LogSnag