I wrote this and its working fine with everything but when I have an empty list
in a given list(given_list=[[],1,2,3]) it saying index is out of range. Any help?
If the nesting is arbitrarily deep, you first need recursion to untangle it:
def items(x):
if isinstance(x, list):
for it in x:
for y in items(it): yield y
else: yield x
Now, max(items(whatever)) will work fine.
In recent releases of Python 3 you can make this more elegant by changing
for it in x:
for y in items(x): yield y
into:
for it in x: yield from it