Skip to content

Commit 156bd89

Browse files
authored
Create Summerof'69.py
1 parent ccd13ab commit 156bd89

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Summerof'69.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""SUMMER OF '69:
2+
Return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and extending to the next 9 (every 6 will be followed by at least one 9). Return 0 for no numbers.
3+
4+
summer_69([1, 3, 5]) --> 9
5+
summer_69([4, 5, 6, 7, 8, 9]) --> 9
6+
summer_69([2, 1, 6, 9, 11]) --> 14
7+
"""
8+
9+
def summer_69(arr):
10+
total = 0
11+
add = True
12+
for num in arr:
13+
while add:
14+
if num != 6:
15+
total += num
16+
break
17+
else:
18+
add = False
19+
while not add:
20+
if num != 9:
21+
break
22+
else:
23+
add = True
24+
break
25+
return total
26+
27+
a=list(input("Enter list: "))
28+
summer_69(a)

0 commit comments

Comments
 (0)