0
how to determine where is list where is not?
7 odpowiedzi
+ 2
You should try with isinstance(variable, list).
I am not really sure what type is a list, but I think it's that one.
But you could always override the "magic method" for isinstance to give the function the behaviour you want
+ 1
Refine your thought, please. I don't understand what you mean
+ 1
I mean are there some attribute or function that can be let we know it's a list or not
+ 1
no : a string also has the square brackets
+ 1
I totally agree with Amaras A.
simply check, if isinstance(e,list):
if you want to find if it is a list or tuple you can add tuple
if isinstance(e,(list,tuple))
0
actually your question is good...we can find list by the square bracket [ ]
0
you can use print type(variable_name)