+ 2
Showing errors!
At the last part it showing List object is not callable why?? https://code.sololearn.com/c3cKEgdtazs7/?ref=app
5 Answers
+ 3
print( list( c.elements() ) ) # error. What are you trying here.. Do you want list of elements?
edit: oh ... you Overiden the list, str...
+ 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?
+ 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..
+ 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.
+ 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