Can someone please explain how line of code in bold is working?
#Write your function here
def middle_element(lst):
if len(lst) % 2 == 0:
sum = lst[int(len(lst)/2)] + lst[int(len(lst)/2) - 1] #HOW DOES THIS LINE OF CODE WORK?
return sum / 2
else:
return lst[int(len(lst)/2)] #HOW DOES THIS LINE OF CODE WORK?
#Uncomment the line below when your function is done
print(middle_element([5, 2, -10, -4, 4, 5]))
Ty