Using break with sum()?

I’m doing the second exercise on the advanced loops challenges and have written:

def over_nine_thousand(lst):
return sum(lst)
if (sum(lst) > 9000):

However, this gives me a syntax error. Does that mean the sum() function does not work like a loop? Do I have to rewrite this with a for loop?

Yes, rewriting this as a loop will allow you to use the break keyword to terminate the summation at a specific value.

Also, it looks like you’ve written some lines below the return in your function. Remember that using a return will end the function immediately, so the remaining lines will not execute even if they were written correctly!

Got it, thank you for the help!