+ 3

# how unpack Nested list?

example 1: for example lst = [1, 2, [3, [4, 5, [6]], 7], 8] now how unpack it like this >>> [[1, 2, 8], [3, 7], [4, 5], [6]] example 2: lst = [1, [2, [[6]]], [[[7]]]] >>> [[1], [7], [7], [7], [2, 6], [6]]

1 Answer

+ 1

You can do that if you use the same nesting structure on the left side:
```
a, (b, c) = [1, [2, 3]]
print(f"{a=} {b=} {c=}")
```
Also you can add extra parentheses to demonstrate the same structure and make it a little bit clear:
```
(a, (b, c)) = [4, [5, 6]]
print(f"{a=} {b=} {c=}")
```
https://code.sololearn.com/cIPr0kwXyn8L/?ref=app