Greater than not equal to 9000

This is my code, it returned the right result but however the solution to this exercise is a bit different

def over_nine_thousand(lst):
  sum1 = 0
 
  for numbers in lst:
    sum1 += numbers
    if sum1 >= 9000:
      break
  if sum1 >= 9000:
    return sum1
  elif sum1 < 9000:
    return sum1
  else:
    return 0

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

Hi @fingertier,

The instructions include this:

The function should sum the elements of the list until the sum is greater than 9000 .

Based on that specification, what should be the output from this statement?:

print(over_nine_thousand([3000, 6000, 800, 2000]))

Edited on August 22, 2019 to note the following:

The instructions require that we continue to iterate through the elements of the list until the sum goes beyond 9000, unless we have exhausted the list. However the following if block will execute a break even if the sum merely equals 9000:

    if sum1 >= 9000:
      break

Consider the following list:

[3000, 6000, 800, 2000]

When 6000 gets added to the sum, we have reached exactly 9000. In that case, we should continue to add to the sum, because we have not yet exceeded 9000, and there are still remaining items in the list.

Given that list, the function, as written in the original post, will return 9000, when it should instead return 9800.

With this statement, the function, as given, does produce the correct result:

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

However, with this statement it does not:

print(over_nine_thousand([3000, 6000, 800, 2000]))