I have a list of tuples with the following fields:
tappeto.storico = [(date, nr_bought)]
I want to increase nr_bought if date == current_date. If I use the explicit way:
for item in tappeto.storico:
if item.date == current_date:
item.nr_bought += 1
break
works perfectly but if I try to use the list comprehension:
[item.nr_bought + 1 if item.date == current_date for item in tappeto.storico]
it goes through the items but looks like the if statement doesn't work. Where am I wrong?