Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ''' We need to apply a discount for customers who purchased more than 500 dollars worth of product – they’re starting to complain it hasn’t been applied. They need to get 10% off on their orders.
- Can you quickly apply a discount? Store the new prices in a list called discounted_subtotals. '''
- subtotals = [15.98, 899.97, 799.97, 117.96, 5.99, 599.99]
- discounted_subtotals = list(map(lambda x: x - (x*0.1) if x > 500 else x, subtotals))
- discounted_subtotals
- # OR
- discounted_subtotals_ = list(map(lambda x: x * 0.9 if x > 500 else x, subtotals))
- discounted_subtotals_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement