Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Flatten List in Python Using Without Recursion

def flatten_list_without_recursion(non_flatten_list):
     
    List = []
     
    while non_flatten_list: 
         
            empty = non_flatten_list.pop()
             
            if type(empty) == list: 
                 
                    non_flatten_list.extend(empty)
            else:
                 
                    List.append(empty)
             
    List.sort()
     
    return List
l= [[0, 1], [[5]], [6, 7]]
flatten_list_without_recursion(l)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Flatten #List #Python #Using #Without #Recursion
ADD COMMENT
Topic
Name
7+2 =