Tell us what’s happening:
My code gives me a synatax error on the lambda(expense) i have no idea why and i’ve been sit here stuck for 1 hour
Your code so far
# User Editable Region
def add_expense(expenses, amount, category):
expenses.append({'amount': amount, 'category': category})
def print_expenses(expenses):
for expense in expenses:
print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')
def total_expenses(expenses):
lambda(expense)
expenses = []
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
Learn Lambda Functions by Building an Expense Tracker - Step 17
Teller
July 25, 2024, 2:45am
2
Welcome to the forum @Mr.Merati
Here is a brief article on how to structure lambda
functions you may find useful.
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
Happy coding
Mr.Merati:
def add_expense(expenses, amount, category):
expenses.append({'amount': amount, 'category': category})
def print_expenses(expenses):
for expense in expenses:
print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')
def total_expenses(expenses):
lambda(expense)
expenses = []
still doesn’t work i have now got this def total_expenses(expenses):
x = lambda expense: expense[‘amount’]
print(x) via chat gpt and w3 schools it doesnt work nothing works
what should i do now ?
ive got this .def total_expenses(expenses):
x = lambda expense: expense[‘amount’]
print(x) still dont work
I just looked up Bro Code on YouTube and he explained it. Usually, it’s better to recommend an actual person on YouTube rather than just a random website with words. Modern learning through ChatGPT is so good and that’s what helped me. Thanks for helping, I appreciate you, my friend.
3 Likes