test_list = [4, 12, 7] def middle_element(l): # middle = l[ int(len(l) / 2) ] middle = l[ len(l) // 2 ] return middle print(middle_element(test_list))