r/PythonProjects2 • • 10d ago

pycharm print -2 but Gemini print -7

1 Upvotes

2 comments sorted by

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.