-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreak.py
More file actions
18 lines (16 loc) · 684 Bytes
/
break.py
File metadata and controls
18 lines (16 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'''
Create a function named over_nine_thousand() that takes a list of numbers named lst as a parameter.
The function should sum the elements of the list until the sum is greater than 9000.
When this happens, the function should return the sum.
If the sum of all of the elements is never greater than 9000,
the function should return total sum of all the elements. If the list is empty, the function should return 0.
For example, if lst was [8000, 900, 120, 5000], then the function should return 9020.
'''
def over_nine_thousand(lst):
sum = 0
for number in lst:
sum += number
if (sum > 9000):
break
return sum
print(over_nine_thousand([8000, 900, 120, 5000]))