You’ve used the same name, list
, for both a built-in type and a local variable. Don’t re-use the built-in names. Quoting PEP-8:
If a function argument’s name clashes with a reserved keyword, it is generally better to append a single trailing underscore rather than use an abbreviation or spelling corruption. Thus
class_
is better thanclss
. (Perhaps better is to avoid such clashes by using a synonym.)
Try:
def funct2(list_):
if type(list_) == list:
...
Or, better:
def funct2(list_):
if isinstance(list_, list):
...
solved Why does python give me a TypeError for this function? (new to coding) [closed]