python - Object of type int is not iterable -


here code:

num = 3                 = [1,5,6,2,8,4,3,2,5] b = [] m = [] check = false summ=0 n = len(a) / num while check == false:      in a:         if a.index(i) >= n:             b.append(m)             m = []             n *= 2         m.append(i)     b.append(m)     j in b:         s1=(sum(b[0]))         s2=(sum(b[1]))         s3=(sum(b[2]))     print(b)     if s1==s2==s3:         summ=s1         check = true     else:         b = [0] * len(a)         ilg = len(a)         b[0]=a[ilg-1]         in range(len(a)-1):             b[i+1] = a[i]         in range(len(a)):             a[i]=b[i] 

what trying split list 3 lists , if sum of numbers in lists equal print sum out, if not print 'false'. example: [1,2,3,4,5,6,7,8,9], after split: [1,2,3],[4,5,6],[7,8,9] getting error: s1=[sum(b[0])] typeerror: 'int' object not iterable doing wrong?

edit: here have more, part after else should change list [1,5,6,2,8,4,3,2,5] [5,1,5,6,2,8,4,3,2] , on.

your problem line:

b[0]=a[ilg-1] 

you're assigning integer b[0], not iterable object. on second iteration around loop, pass b[0] sum function, attempts iterate on it, throwing exception.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -