how to find the middle number in python
Put them in a list, sort them, pick the middle one.
>>> x = [1,3,2]
>>> sorted(x)[len(x) // 2]
2
The fastest obvious way for three numbers
def mean3(a, b, c):
if a <= b <= c or c <= b <= a:
return b
elif b <= a <= c or c <= a <= b:
return a
else:
return c