-1
我試圖把我的代碼更新mostComp每次的值檢測到一個因素,量越大的數字,但保持比較列表被遇到了:無法對一些
TypeError: unorderable types: list() > int()
我目前擁有的代碼如下:
def MostComposite(integers):
#The item in sequence 'integers' of positive integers which has
#the greatest number of distinct factors, returns None if the sequence is empty.
mostComp = 0
for i in integers:
if (Factors(i)) > 0:
mostComp += i
if (Factors(i)) > mostComp:
mostComp += i
return mostComp
你比較'因素(我)'返回一個列表,'0'是一個整數。 –
你大概想'len(因素(我))' –
我已經解決了這個問題,但是代碼仍然沒有返回具有最大分解因子的整數項,如果你不介意的話,你能請指向正確的方向。 – Tigerr107