+ 6
'list' object is not callable = error
i'm using python3.7 when i run this numbers = list(range(10)) this generates error 'list' object is not callable any solution?
12 Answers
+ 10
As Flandre Scarlet has pointed out you might have done something like this =>
>>> list = []
>>> list(range(10)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'list' object is not callable
>>>
That's why you are getting this error because you have overwritten the built-in list() function with a variable containing a list or some other object.
+ 5
you may have named something to be 'list', so that 'list' is not a function anymore
+ 4
are you attempting to make a list with the numbers 0-9? Try this..
numbers=[i for i in range(10)]
Look into List Comprehension
+ 3
you should try:
numbs = [i for i in range(0, 10)]
as Rick Morty said
this will create:
numbs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
this can be written as:
numbs = []
for i in range(0, 10):
numbs.append(i)
but that would be very inefficient and not recommended
+ 3
Please upload your coding
anything else is Teesatzleserei(German) or asking the oracle of Delphi
+ 2
numbers = list(range(10))
this is working now ! i dont know how there was an error ! bytheway thankuh Peeps for Your time !
+ 2
Ooflamp It's designed that all built-in functions can be overwritten so that you can use them as how you want to
+ 1
Why you got error this is right.
numbers=list(range(10))
print(numbers)
+ 1
I am using Python3.7 too but this code can work and output right result
Check you code again
0
Why does python allow name collision?
0
Oh okay, Thanks
- 4
https://www.techbroot.com/2018/08/how-to-get-free-gift-cards-online-with.html
https://www.techbroot.com/2018/08/remove-powered-by-shopify-link-from-footer.html
https://www.techbroot.com/2018/08/how-to-sell-clash-of-clans-accoun.html
https://www.techbroot.com/2018/08/install-and-configure-airwatch-cloud-connector.html
https://www.techbroot.com/2018/08/how-to-stop-windows-defender-legitimate-trojans.html