Learn Lambda Functions by Building an Expense Tracker - Step 16

please improve my coding

Your code so far

/* User Editable Region */

def total_expenses(expenses):
    total = sum(map(lambda expense: expense['amount'], expenses))
    return total

/* User Editable Region */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Learn Lambda Functions by Building an Expense Tracker - Step 16

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hi, welcome to the forum!
We see you have posted some code but did you have a question?

(You have not filled out the “Tell us what’s happening:” field above)

please correct my coding

You should really ask a more specific question so I can help you to understand. Is there something you’re unsure about?

Here is some information about lamba functions:

syntax for lambas:

x = lambda a : a + 10

Here the result will be returned to the variable x

Use expense as the parameter and return the value of the amount key in the expense dictionary.

The expense dictionary will take the place of a in the syntax example.

Please let me know if you have a more specific question

1 Like