Say I have a list like
cata = [["Shelf", 12, "furniture", [1,1]],
["Carpet", 50, "furnishing", []]]
and I want to find out in each nested list if it's empty or not.
I am aware of using for loops to iterate through the lists, and if statements to verify as I have in a function
def myfunc(cata):
for inner in cata:
for inner_2 in inner[3]:
if inner_2:
return "True"
else:
return "False"
However instead of returning:
'True'
'False'
All I get is:
'False'
Is there some method of searching nested loops that I'm missing?
return [str(bool(inner[3])) for inner in cata]'True'and'False'instead of the boolean valuesTrueandFalse. Are you certain this is what you want?