I'm practicing nested lists comprehension and i encountered some problems i cannot solve nor find any solutions online :<
nested_lista = [[2,1,2,3],[1,2,3,4],[4,4,[16,1,3]]]
Using loops its easy to iterate through every layer of this nested list
def nested_loops():
for x in nested_lista:
for y in x:
print(y)
if type(y) == list:
for z in y:
print(z)
Output:
2
1
2
3
1
2
3
4
4
4
[16, 1, 3]
16
1
3
Now im trying to achieve similar output with nested list comprehension but it's not working no matter what i try ;/
Here's what I've come up with:
[[[print(y) for y in z if type(z)==list]print(z) for z in x]for x in nested_lista]
or at least i tried to iterate through last layer but it also doesnt work
[[[print(y) for y in z if type(z)==list] for z in x]for x in nested_lista]
Is it possible to solve this or i should give up?