Purify


#1

Practice Makes Perfect - Purify

Traceback (most recent call last):
File “python”, line 8, in
File “python”, line 5, in purify
TypeError: ‘builtin_function_or_method’ object has no attribute ‘getitem

I feel like I’m missing something really small - can’t find the mistake.



def purify(x):
  evens = []
  for i in x:
    if i % 2 == 0:
      evens.append[i]
  return evens

print purify([1,2,3,4,5,6,7,8,9,10]) 



#2

.append() is a method, callnig it requires parentheses. Square brackets is for accessing list/string by index and dictionaries by key


#3

I found it just as you replied. Thank you.


#4