Help understanding Python Code Challenge: Middle Item

It is asking for a list that has an odd number of inputs, then to return the middle value. This is coded under the else: statement. Can someone explain how that code works? It appears to me that the code would return “lst[2.5]”, which can’t be indexed, and not “lst[2]”, which is the middle index value.
def middle_element(lst):

if len(lst) % 2 == 0:
sum = lst[int(len(lst)/2)] + lst[int(len(lst)/2) - 1]
return sum / 2
return lst[int(len(lst)/2)]

It is because it is using the int() function.

what does the int() function change a float??

It makes the number the number before the decimal places. For example, int(3.8) is 3. Or int(76.3) is 76.

Oh perfect thank you!

You’re welcome!
Happy coding!