[Tutor] Summing arrays

Aaliyah Ebrahim aaliyahebrahim21 at gmail.com
Thu Mar 16 01:11:47 EDT 2017

Hi guys! I hope you can assist me with understanding and fixing my error
below. Thanks for this amazing forum :)

def sum2(N):

    b = np.arange(1,N+1,1)
    mylist = [ ]
    for i in b:

        terms = 2*(1+3**(i-1))
        a = mylist.append[terms]
    return np.sum(mylist)


                                Traceback (most recent call
last)<ipython-input-65-bc89ed710705> in <module>()     10     return
np.sum(mylist)     11 ---> 12 print(sum2(N=50))
<ipython-input-65-bc89ed710705> in sum2(N)      7       8
terms = 2*(1+3**(i-1))----> 9         mylist.append[terms]     10
return np.sum(mylist)     11
TypeError: 'builtin_function_or_method' object is not subscriptable


More information about the Tutor mailing list