Hello, just like the title, [[0], [[1, 2, [3, 4]], [5, 6, 7], [8, 9, 10], [11, 12, 13]]] I want to get the maximum value from the list I have no idea how to approach it.
In the list, 1*1, 2*2, 3*3... I want to get the maximum value in the list of n*n-shaped matrices, so I wonder how to code. It would be nice if the listed list had the same form, but I'm asking because I can't find the answer even if I googled.
python list
Please keep that in mind
def deepflatten(iterable, depth=None, types=None, ignore=None):
if depth is None:
depth = float('inf')
if depth == -1:
yield iterable
else:
for x in iterable:
if ignore is not None and isinstance(x, ignore):
yield x
if types is None:
try:
iter(x)
except TypeError:
yield x
else:
yield from deepflatten(x, depth - 1, types, ignore)
elif not isinstance(x, types):
yield x
else:
yield from deepflatten(x, depth - 1, types, ignore)
L = [[0], [[1, 2], [3, 4]], [[5, 6, 7], [8, 9, 10], [11, 12, 13]]]
max(list(deepflatten(L)))
13
© 2025 OneMinuteCode. All rights reserved.