# Dead after running list_ = [0, [2, 3, [5, 4], 6, 5], [3, 4, 5], 6, 7, 9] def flattening(list_): list1 = [] for item in list_: if type(item)!= list: list1.append(item) else: # type(item)!= list: list1.extend(item) return flattening(list_); print(list1) flattening(list_)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter