 # Help with over 9000

I’m stuck at over 9000 challenge.

When I run the code I get 9020 on the right. But I get an error saying “should have returned 8900, and it returned none.”

The instructions say for the lst that’s given that it should return 9020. What am I missing here?

Here is my code.

``````def over_nine_thousand(lst):
lst_sum = 0
for i in lst:
lst_sum += i
if lst_sum == 0:
return 0
if lst_sum > 9000:
return lst_sum

print(over_nine_thousand([8000, 900, 120, 5000]))

``````

Hello, @arcmaster84335, and welcome to the Codecademy Forums!

Your function should produce the correct result for any list of numbers that it is passed as an argument.

What would your function return for the following call?:

``````print(over_nine_thousand([8000, 900]))
``````

Also consider what the result would be with this function call:

``````print(over_nine_thousand([0, 0, 5000, 1000, 4000]))
``````

ah, ok. So this is actually doing multiple checks? And since I only half-assed the script… It’s failing.
Thanks!

For any algorithm we develop or code we write, we should try to think of cases that we must take into account in order for our testing to be thorough. The examples Codecademy provides are not necessarily sufficient by themselves. For the current problem, some cases to consider include:

• a list that begins with a negative number.
• a list that begins with `0`.
• a list that begins with a positive number less than `9000`.
• a list that begins with `9000`.
• a list that begins with a number greater than `9000`.
• a list wherein the numbers add up to a sum of less than `9000`.
• a list wherein the numbers add up to exactly `9000`.
• a list wherein the numbers add up to a sum greater than `9000`.
• a list wherein the sum of all the numbers is greater than `9000`, and where at some point the partial sum is exactly `9000`.
• a list wherein the sum of all the numbers is greater than `9000`, but where the partial sum is never exactly `9000`.

We do not need to provide a separate `if`, `elif`, or `else` block for each case. We just need to make sure that our code delivers a correct solution for every case. Boundary conditions commonly form a situation where a tentative solution fails.

2 Likes