def shallowfy(lista):
shallow = []
for el in lista:
if (isinstance(el, list)):
shallow_el = shallowfy(el)
for subel in shallow_el:
shallow.append(subel)
else:
shallow.append(el)
return shallow
print(shallowfy([1, 2, [[[3, [4], 5, [6, 7, [[8, 9], 10, [11]], 12], 13], 14], 15], 16, [17, [[[18]]], 19], 20]))
print(shallowfy([[1, 2], [3, 4, 5], [], [6, 7]]))
ZGVmIHNoYWxsb3dmeShsaXN0YSk6CiAgICAgIHNoYWxsb3cgPSBbXQogICAgICBmb3IgZWwgaW4gbGlzdGE6CiAgICAgICAgaWYgKGlzaW5zdGFuY2UoZWwsIGxpc3QpKToKICAgICAgICAgIHNoYWxsb3dfZWwgPSBzaGFsbG93ZnkoZWwpCiAgICAgICAgICBmb3Igc3ViZWwgaW4gc2hhbGxvd19lbDoKICAgICAgICAgICAgc2hhbGxvdy5hcHBlbmQoc3ViZWwpCiAgICAgICAgZWxzZToKICAgICAgICAgIHNoYWxsb3cuYXBwZW5kKGVsKQogICAgICByZXR1cm4gc2hhbGxvdwogICAgICAKcHJpbnQoc2hhbGxvd2Z5KFsxLCAyLCBbW1szLCBbNF0sIDUsIFs2LCA3LCBbWzgsIDldLCAxMCwgWzExXV0sIDEyXSwgMTNdLCAxNF0sIDE1XSwgMTYsIFsxNywgW1tbMThdXV0sIDE5XSwgMjBdKSkKcHJpbnQoc2hhbGxvd2Z5KFtbMSwgMl0sIFszLCA0LCA1XSwgW10sIFs2LCA3XV0pKQo=
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
[1, 2, 3, 4, 5, 6, 7]