Answers for "middle value of a list in python"

1

middle value of a list in python

def findMiddle(input_list):
    middle = float(len(input_list))/2
    if middle % 2 != 0:
        return input_list[int(middle - .5)]
    else:
        return (input_list[int(middle)], input_list[int(middle-1)])
Posted by: Guest on December-09-2020
0

middle value of a list in python

[lis[i] for i in 
    range((len(lis)/2) - (1 if float(len(lis)) % 2 == 0 else 0), len(lis)/2+1)]
Posted by: Guest on December-09-2020

Code answers related to "middle value of a list in python"

Python Answers by Framework

Browse Popular Code Answers by Language