12. purify (French version) "Your code fails on [4, 5, 5 ,4] because 'list' object is not callable" when it actually runs smoothly


#1


https://www.codecademy.com/fr/courses/python-intermediate-fr-FR-py0yl/2/2

Hello everyone,
Codecademy returns an error message when applying the function to the list [4, 5, 5, 4] when actually I don't see any problem. Am I really doing something wrong ?


The error message " 'list' object is not callable" doesn't make any sense to me in this situation, even if I think I know where it comes from, because it was an error that was present in a former version of my function.

I tried refreshing the page, logging out and in again, in different browsers and even in private mode but it didn't make any difference.

Here are current and former versions of my code :

#current version
def purifier(liste):
    liste_pairs = []
    for i in liste:
        if i % 2 == 0:
            liste_pairs.append(i)
    
    return liste_pairs


# Former version

def purifier(liste):
    liste_pairs = []
    for i in range(len(liste)):
        if liste[i] % 2 == 0:             #first errors occurred because I wrote liste(i) instead of liste[i]
            liste_pairs.append(liste[i])
    
    return liste_pairs

Thanks in advance for any help ! :slightly_smiling: