+ 2

Showing errors!

At the last part it showing List object is not callable why?? https://code.sololearn.com/c3cKEgdtazs7/?ref=app

25th Nov 2022, 1:26 PM
Mustakim Rahman
Mustakim Rahman - avatar
5 Respuestas
+ 3
print( list( c.elements() ) ) # error. What are you trying here.. Do you want list of elements? edit: oh ... you Overiden the list, str...
25th Nov 2022, 1:55 PM
Jayakrishna 🇮🇳
+ 3
It should output like if p=4, then it should show (p, p,p,p,) q=2, then( q,q) But list object is not callable why?
25th Nov 2022, 2:01 PM
Mustakim Rahman
Mustakim Rahman - avatar
+ 3
list is no more predefined list so you can try : print( *c.elements() , sep=',') print( ','.join( c.elements() ) ) print( sorted(c.elements() ) edit: yes.. print(list(c.elements())) is also works if you not use list as variable previously.. don't use predefined keywords as variables.. don't use list, str as variables.. find some other..
25th Nov 2022, 2:10 PM
Jayakrishna 🇮🇳
+ 1
You created variable 'list" in the first routines (see lines 40 and 47). This way, you overwritter function 'list'. When you try to call 'list (something)', you end up calling the variable - which is not callable indeed. Never use reserved words for anything else, in any language, unless you're absolutely sure of what you're doing.
25th Nov 2022, 11:09 PM
Emerson Prado
Emerson Prado - avatar
+ 1
List object is not callable. You think it's the python default list but you overwrote its name (line 24) so you can change that list name to something else like "_list" or "list0". Also you overwrote str name (line 40), so change it too. Next time don't using python default types/objects names to name your own variables
26th Nov 2022, 9:48 AM
Sousou
Sousou - avatar