Reputation: 1
Only include products that are non-discontinued (discontinued=0) with unit_price greater than 15.0 in the new list.
How I can solve this? How can I select and use discontinued=0
with unit_price and put it into the code?
print (list(filter(lambda x: x=0,>15,products)))
Upvotes: 0
Views: 62
Reputation: 22794
I imagine products are either objects of a certain Product
class, or are dicts, if that's the case, you can use:
discontinued
and unit_price
attributes):print(list(filter(lambda x: x.discontinued == 0 and x.unit_price > 15, products)))
discontinued
and unit_price
keys):print(list(filter(lambda x: x['discontinued'] == 0 and x['unit_price'] > 15, products)))
Upvotes: 2