Create a list and add values depending on variable

Hello,

I am trying to create a list with certain values. If there´s a trial where the lottery is won, the list should include the value of another variable (lotteryprice) for this line.
If the lottery is lost, ther should be a zero in the list for that trial. Here is the code I am currently using for that:

lottery_bid_sub_subset = []

for index, lotteryprice in lottery_price_subset.iteritems():
    if fbMsg == 'Gewonnen':
        lottery_bid_sub_subset.append(lotteryprice)
    else:
        lottery_bid_sub_subset.append(0)

Unfortunately the code only leads to the effect that if the last of all trials is won, I get the whole list with the values from the other list while I get a whole list of zeros if the last trial is lost. How can I make the code check the fbMsg for every single line?

Why are you trying to build the list at the end?

I would put lottery_bid_sub_subset = in Begin Experiment and then append lotteryprice or 0 in End Routine of the trial where fbMsg is set.