Answers for "def flatten(lst): """ Takes a nested list and "flattens" it."

4

flatten nested list

def flatten(x):
    if isinstance(x, list):
        return [a for i in x for a in flatten(i)]
    else:
        return [x]
Posted by: Guest on May-17-2021

Code answers related to "def flatten(lst): """ Takes a nested list and "flattens" it."

Python Answers by Framework

Browse Popular Code Answers by Language