0

callable object in python

''' An array 'a' is divided into two sub arrays 'b' and 'c' such that difference of the sums of elements in the respective sub arrays is minimum e.g a = [2,5,4,7,15,20] b = [20,7,4] c = [15,5,2]''' a = [2,5,4,7,15,20] b = [] c = [] while len(a) != 0: val = a.pop(a.index(a(max))) b.append(val) val = a.pop(a.index(a(max))) c.append(val) print (b) print (c) print (sum(b)-sum(c)) ......please someone fix the error

25th Jun 2019, 3:16 PM
Hassan Bari Raza
Hassan Bari Raza - avatar
2 ответов
+ 2
val = a.pop(a.index(a(max))) 👇 val = a.pop(a.index(max(a)))
25th Jun 2019, 3:41 PM
Anna
Anna - avatar
0
I usually do silly mistakes
25th Jun 2019, 4:08 PM
Hassan Bari Raza
Hassan Bari Raza - avatar