need to write a recurive function to remove elements of list but keep the arrays in the result such as.
def remove_words(listx):
for element in listx:
if isinstance(element, list):
remove_words(element)
else:
listx.remove(element)
return listx
remove_words(["a", "b", ["c"]]) would return [[]]
My code returns ["b",[]] for some reason it's missing an element.
listwhile iterating it. Do not do that. You remove the first element and when the index moves on, the new second element is the formerly third... find a way to avoid that!