Close
Close

python returning int as None. Help me

   Bingle98

I’m returning count here, which before the return statement gives <type ‘int’> but after it gets returned the output I get is None.

please help me, I’m fairly new to coding and this is driving me insane

def eq(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

    eq(arr,count)

   
   
a=[10,7,12]
print(eq(a,0))

  • Take out the print(count) in the. function , Just return
    - dennisthegoat

Answers

Ask Yours
Post Yours
Write your answer