前提・実現したいこと
checkioというサイトで多次元のリストが空かどうかを調べる問題を出されました。
問題は以下の通りです
You need to figure if a wellfounded and wellsized iterable is completely empty.
An iterable x0 is wellfounded if there is no infinite sequence
x1,x2,x3... such that ... in x3 in x2 in x1 in x0 (where in is meant iteratively, x(n+1) will be encountered while iterating through xn).
A wellfounded iterable is wellsized if it has only finitely many iterable elements, and all of them are wellsized.
A wellfounded iterable is completely empty when all its elements are completely empty.
Some consequences of the above definitions:
any empty iterable is completely empty
a non-iterable is never completely empty
the only wellfounded string is '', and it is completely empty
bytes, and (possibly nested) tuples/frozensets of them are always wellfounded and wellsized
{'': 'Nonempty'} is a wellfounded and completely empty iterable
after c=[];c.append(c), c is a non-wellfounded iterable
itertools.repeat(()) is wellfounded but not wellsized
itertools.repeat(5) is wellfounded and wellsized
Input: A wellfounded and wellsized iterable.
Output: A bool.
発生している問題・エラーメッセージ
今のコードだとうまく判別できないリストがあります
どう変えれば良いか教えていただきたいです
エラーメッセージ Your result:True Right result:False Fail:completely_empty([[],[1]])
該当のソースコード
ソースコード if len(val) ==0: return True else: try: for i in range(len(val)): if not val[i]: return True else: try: for m in range(len(val[i])): if not val[i][m]: return True else: return False except: return False except: return False
試したこと
おそらく下から4行目のreturn TrueによってTrueになってしまっているようなのですがどう変えれば良いかわかりません
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。