# Learn Lambda Functions by Building an Expense Tracker - Step 33

**URL:** <https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217>\
**Category:** Curriculum Help\
**Created:** [December 9, 2024, 10:49am UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217 "2024-12-09T10:49:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![LyaTeam](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LyaTeam](https://forum.freecodecamp.org/u/LyaTeam)\
**Post date:** [December 9, 2024, 10:49am UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/1 "2024-12-09T10:49:45Z")

</div>

### Tell us what’s happening:

What’s going on? i doesn’t stop looping…!

### Your code so far

```py
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):
    return sum(map(lambda expense: expense['amount'], expenses))
    
def filter_expenses_by_category(expenses, category):
    return filter(lambda expense: expense['category'] == category, expenses)

# User Editable Region

def main():
    expenses = []
while True: 
    print('\nExpense Tracker')
        

    

# 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/131.0.0.0 Safari/537.36 Edg/131.0.0.0`

### Challenge Information:

Learn Lambda Functions by Building an Expense Tracker - Step 33

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/step-33)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![AlexK](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@AlexK](https://forum.freecodecamp.org/u/AlexK)\
**Post date:** [December 9, 2024, 10:56am UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/2 "2024-12-09T10:56:46Z")

</div>

Looks like you might be missing the closing statement

---

<div class="post-metadata">

**Author:** ![LyaTeam](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LyaTeam](https://forum.freecodecamp.org/u/LyaTeam)\
**Post date:** [December 9, 2024, 11:01am UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/3 "2024-12-09T11:01:07Z")

</div>

Thanks for the reply, shall I add: main()

---

<div class="post-metadata">

**Author:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [December 9, 2024, 11:19am UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/4 "2024-12-09T11:19:14Z")

</div>

Remember Python uses indentation to determine which code goes together. Because the while loop is not indented, it is considered as being in global scope. This it is executed when code runs and loop prints over and over again.

As per instructions, the loop should be added within the `main` function.

---

<div class="post-metadata">

**Author:** ![LyaTeam](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LyaTeam](https://forum.freecodecamp.org/u/LyaTeam)\
**Post date:** [December 9, 2024, 12:11pm UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/5 "2024-12-09T12:11:09Z")

</div>

I indented the print, but is still not passing !

---

<div class="post-metadata">

**Author:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [December 9, 2024, 12:36pm UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/6 "2024-12-09T12:36:50Z")

</div>

What’s your updated code?

---

<div class="post-metadata">

**Author:** ![LyaTeam](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LyaTeam](https://forum.freecodecamp.org/u/LyaTeam)\
**Post date:** [December 9, 2024, 1:24pm UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/7 "2024-12-09T13:24:40Z")

</div>

```auto
while True:
             print('\nExpence Tracker')

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [December 9, 2024, 1:27pm UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/8 "2024-12-09T13:27:25Z")

</div>

please start from `def main` and give the code from that line to the end

---

<div class="post-metadata">

**Author:** ![pkdvalis](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/pkdvalis/32/350571_2.png) [@pkdvalis](https://forum.freecodecamp.org/u/pkdvalis)\
**Post date:** [December 9, 2024, 1:43pm UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/9 "2024-12-09T13:43:51Z")

</div>

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (').

---

<div class="post-metadata">

**Author:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [December 9, 2024, 2:10pm UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/10 "2024-12-09T14:10:32Z")

</div>

Whole loop should be in function.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [June 10, 2025, 2:10am UTC](https://forum.freecodecamp.org/t/learn-lambda-functions-by-building-an-expense-tracker-step-33/724217/11 "2025-06-10T02:10:55Z")

</div>

Closed on June 10, 2025, 2:10am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
