Find Element in List || List || Python
In this we are going to see a basic program to get Middle Element in the List in Python Programming Language.

list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
print("The List : ", list1)
print("---------------------------------------------------------------")
if len(list1) % 2 == 0:
    i = int(len(list1) / 2)
    print("The Middle Element Is : ", list1[i - 1:i + 1])
else:
    print("The Middle Element Is : ", list1[int((len(list1) - 1) / 2)])

# Coded By DHIRAJ SHELKE

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post