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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -