Consider the following command:
elite_states = [s for i in range(len(states_batch))
if rewards_batch[i]>=reward_threshold for s in states_batch[i]]
I found that is equivalent to the following loop:
_l=[]
for i in range(len(states_batch)):
for s in states_batch[i]:
if rewards_batch[i]>=reward_threshold:
_l.append(s)
However I don't get how the loop after s
in the first command becomes the outer loop in its equivalent. I want to understand the format of the command so I get how it works!