I have a nd python array (not a numpy array), and it looks something like this
[[[1,2,3], [4,5,6]]]
I'd like to be able to remove all the unnecessary arrays so that I end up with
[[1,2,3], [4,5,6]]
And I wrote a function to handle this
def remove_unnecessary(array:list) -> list:
while True:
try:
array = *array
except TypeError:
return array
However this doesn't work, and that's mainly due to my lack of knowledge on using starred expressions to unwrap lists. Does anyone have an idea on how I could fix this or how I could better use * in this function?