python - TypeError: 'int' object is not iterable? -


i implementing dynamic programming algorithm , got error. code:

def shoot(aliens):     s=[0]*10     s[0]=0     s[1]=0     j in xrange(2,len(aliens)):         in xrange(0,j):            s[j]=max(s[i] + min(aliens[j],fib(j-i))) <---error here     print s[len(aliens)-1]     return s[len(aliens)-1]  def fib(n):     if n == 0:         return 0     if n == 1:         return 1     return fib(n-1) + fib(n-2)  aliens=[1,10,10,1] print shoot(aliens) 

it says that:

traceback (most recent call last): file "module1.py", line 30, in <module> print shoot(aliens) file "module1.py", line 19, in shoot s[j]=max(s[i] + min(aliens[j],fib(j-i))) typeerror: 'int' object not iterable 

please me

update: oh, it. mean

s[j]=max(s[i] + min(aliens[j],fib(j-i))) 

but im wrong. so, edited that, not know how use max() take out largest in array.

    b=0     j in xrange(2,len(aliens)):         in xrange(0,j):            a[b]=(s[i] + min(aliens[j],fib(j-i)))            b+=1         s[j]=largest(a[b]);   <--how can max() function 

max , min functions require several arguments or range of elements. call min() has 2 arguments (ok), call max() has one. not sure want maximize here...


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -