Optimized for loop python -
okay so, while solving problem going through else's code , implemented kind of statement not familiar in python. sorry new python , google searches did not me this.
distance, food = min([(util.manhattandistance(state, food), food) food in foodlist])
i kind of understand loops minimum value of food or distance or something, not sure.
the 1 line of list comprehension translates loop, , assignment
food in foodlist: food_list.append(util.manhattandistance(state, food), food) <--> value of min_value = min(food_list)
Comments
Post a Comment