For example,
list1 = [1,2,[5,[6],8],7]
n = 3
How can i make so it removes n
elements while accessing the sublists? Considering n = 3 it would remove 1,2 and the 5 out of [5,[6],8], not the entire sublist, making it become [[6],8]
I know i can access all sublist levels by using recursion:
list1 = [1,2,[5,[6],8],7]
def print_all(l):
for el in l:
if type(el) == list:
print_all(el)
else:
print(el)
return
print_all(list1)
the output is:
1
2
5
6
8
7
Now I'm stuck on the removing part, any kind of help would be much appreciated. Thank you!