0
def divinding(a):
b=[]
c=[]
a.sort()
for i in a:
if(i%a[0])==0:
b.append(i)
else:
pass
if(len(b)>2):
store(b)
else:
pass
if(len(a)>1):
a.pop(0)
divinding(a)
def store(b):
c=[]
c.append(b)
print c
divinding([2, 11, 16, 12, 36, 60, 71, 17, 29, 144, 288, 129, 432, 993])
列表追加到另一個列表在此代碼獲取所有值seperately如何使用循環
[[2, 12, 16, 36, 60, 144, 288, 432]],[[12, 36, 60, 144, 288, 432]],[[16, 144, 288, 432]],[[36, 144, 288, 432]],[[144, 288, 432]]
,但我需要在一個列表
[2, 12, 16, 36, 60, 144, 288, 432],[12, 36, 60, 144, 288, 432],[16, 144, 288, 432],[36, 144, 288, 432],[144, 288, 432]
這樣所有值。
注意,這會產生有趣的結果,如果函數被調用一次以上。 –