Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+5 votes

On routine practice 7 question 1 it wants us to get the min and max temperatures of the week. I was able to get it working for every scenario except for the one where the input is: -4, -1, 4, 6, 8, 10, 15. Max works fine but min turns out to be the value I assigned to it before the loop. Any tips on how to fix the min value for this specific input?

asked in old_CSC201 by (1 point)

2 Answers

+1 vote

Fixed it by using two separate if statements in the loop.

answered by (1 point)
+1 vote

Lukas fixed his problem in exactly the correct way. If the initial values of max and min are not set to the first data value before the loop, then that should be the effect of the first iteration through the loop.

answered by (1 point)