Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Home - Flatten a List (using recursion) solution in Clear category for Flatten a List by tutek1
def flat_list(array):
result = [] #sets up a list for result
for i in array:
if type(i) is list: #if the current item is a list it calls the function again
result.extend(flat_list(i)) # ==> thus creating a recurring function
else:
result.append(i) #if its just a number it adds it to the list
return result
Sept. 27, 2019