Python has wonderful built-in library “statistics”
We can find out the median of a list with this library easily with less code
import statistics
List = [1,2,3,4,5,6,7,8,9,10]
result= statistics.median(List)
print(result)
We can also generate list randomly with random module
List = [randint(1, 101) for _ in range(50)] this code create a list of 50 random numbers form 1 to 100
import statistics
from random import randint
List = [randint(1, 101) for _ in range(50)]
print("List =",List)
result= statistics.median(List)
print("Median: ",result)