Can you help me understand why this doesn't work?

Hi! Could someone explain why this solution does only return 8000 and does not continue to add other elements but the very first?

def over_nine_thousand(lst):
Sum = 0
while Sum <= 9000:
Sum += lst[n]
return Sum

#Uncomment the line below when your function is done
print(over_nine_thousand([8000, 900, 120, 5000]))

1 Like

Hello, @sofie.s.

My best guess would be the indentation level of your return Sum statement. Please review this topic: How do I format code in my posts?

Happy coding!

P.S. Remember that return always hands a value back to the caller, and terminates the execution of the function.