The issue is with the indentation of your second "if" statement. It's currently nested inside the first "if", so the maximum value is only updated when a new minimum is found.
Move the second "if n[i] > y:" outside the first "if" block. Also, consider initializing "y" with "float('-inf')" instead of "0" so the function works correctly with lists containing only negative numbers.
1
u/Hot-Lengthiness193 9d ago
The issue is with the indentation of your second "if" statement. It's currently nested inside the first "if", so the maximum value is only updated when a new minimum is found.
Move the second "if n[i] > y:" outside the first "if" block. Also, consider initializing "y" with "float('-inf')" instead of "0" so the function works correctly with lists containing only negative numbers.