Calling lambda in-line
Remember, one of the key benefits of lambda is the ability to use functions in-line.
In this exercise, you'll modify the approach of the previous exercise to add tax to the sales_price
variable in-line without storing a lambda function as a variable first.
This exercise is part of the course
Intermediate Python for Developers
Exercise instructions
- In a single line of code, make a lambda function that multiplies
sale_price
by 1.2 and returns the results.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
sale_price = 29.99
# Call a lambda function adding 20% to sale_price
print(____)