Forum Archive

TypeError: 'list' object is not callable

Anik
my_list=[1,2,3,4,5,6,7,8,9,10]
even= list(filter(lambda x : x%2 == 0,my_list))
print(even)

Why does the above code show TypeError: 'list' object is not callable ?(run with Pythonista 3.6)

cvp

@Anik works for me, sure you run in Python 3?

Edit : works also in Python 2.6

Prints

[2, 4, 6, 8, 10]

Edit2: sure that these 3 lines of code do not belong to a bigger script where a variable is called list?

Anik

Thank you for your response.
This code run with python 2.7.
But why does this code show TypeError with python 3.6?

cvp

@Anik For me, this code runs ok in Python 3.6
Did you see my previous question? Is this little code part of a bigger one or do you try these 3 lines alone?

Anik

3 lines alone.

cvp

@Anik Sorry but I can't find an explanation. Did you try to remove Pythonista from memory and restart?

ccc

Works as expected for me.