-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathask8.py
More file actions
25 lines (25 loc) · 766 Bytes
/
ask8.py
File metadata and controls
25 lines (25 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
b=[]
import random
for i in range(30):
a[i]=random.randint(-29,29)
print "List:"
print a
for i in range(30):
x=a[i]
for j in range(30):
if (i != j):
y=a[j]
for k in range(30):
if (j != k):
z=a[k]
if (x+y+z == 0):
b.append(x)
b.append(y)
b.append(z)
if (len(b) != 0):
print "The combinations of three consecutive numbers that add up to 0 are:"
for l in range(0,len(b),3):
print b[l], b[l+1], b[l+2]
else:
print "There are no combinations of three consecutive numbers that add up to 0."