【发布时间】:2020-10-20 14:23:26
【问题描述】:
我在这里返回计数,在 return 语句之前给出 <type 'int'> 但在它返回之后我得到的输出是 None。
def equal(arr,count):
arr = sorted(arr)
if arr[0]==arr[-1]:
print(count) # the answer I’m getting is correct so I don’t
#think there’s a problem with rest of the code
return count
if (arr[-1]-arr[0])>=5:
diff=5
elif(arr[-1]-arr[0])>=2:
diff=2
else:
diff=1
for i in range(len(arr)-1):
arr[i]+=diff
count+=1
equal(arr,count)
a=[10,7,12]
print(equal(a,0)) # I'm getting output here as **None**enter code here
【问题讨论】:
标签: python python-3.x