Greeting everyone! I need help, i have the list with an odd numbers of elements, and i have to find the value placed in the middle of the list. I understand it`s not big deal but my brain is decided to shut down
CodePudding user response:
try this:
l = [1,2,3]
l[len(l)//2]
CodePudding user response:
you first get the length of your list "len(listName)" you can store it in a new variable. The element in the middle of the list is the element at the index length // 2 because the first element of the list have an index of 0 so the element will be: array[len(array) // 2]