The problem is here. Try checking if bestValue is less than the value over the distance function with item as the argument. Other than that, your code is perfect .
your mistake is here, you check if bestValue is bigger, while you should be doing the opposite, you should be checking if its smaller.
P.S. you should use a for loop
for item in items:
value = valueOverDistance(item)
if value > bestValue:
bestItem = item
bestValue = value
# this is the same code except a bit better-formatted
No, don’t use a for-loop. Why? It is not covered in the desert, in the mountain though. I suggest that @Lydia_Song sticks with while loops until she reaches the mountain and so that no one gets confused.
Hmm, it may not be the case but maybe you already had experience with loops before starting CoCo, or maybe you were doing it all over again. @Lydia_Song may be doing this level for the first time and may have not covered for-loops, so I think that she should stick to what she knows before we go off on a tangent .