If we have the following list:
list = [\'UMM\', \'Uma\', [\'Ulaster\',\'Ulter\']]
If I need to find out if an element in the list is itself
Expression you are looking for may be:
... return any( isinstance(e, list) for e in my_list )
Testing:
>>> my_list = [1,2] >>> any( isinstance(e, list) for e in my_list ) False >>> my_list = [1,2, [3,4,5]] >>> any( isinstance(e, list) for e in my_list ) True >>>