Apply Discount with Lambda
Easy
Write a function apply_discount(prices, percent) that takes a list of prices and a discount percentage, and returns a new list with each price reduced by that percentage. Use a lambda function with map().
Input
A list of numbers (prices) and a number (percent, e.g. 10 for 10%).
Output
A list of discounted prices, each rounded to 2 decimal places.
Example
Input
prices=[100, 200, 50], percent=10
Output
[90.0, 180.0, 45.0]
discount_factor = 1 - percent/100. Use map(lambda p: round(p * discount_factor, 2), prices).
10 XP on solve
Back to lesson
Your Solution
Output
Click "Run" to execute your code...
⏳ Loading Python runtime (first run may take a few seconds)...
Log in to submit your solution and earn XP.