Created
July 3, 2017 15:47
-
-
Save katkamrachana/0c4f34f8de8d21b22ceb2b7b0246beae to your computer and use it in GitHub Desktop.
List flatten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list_obj = [[1,2,[3]],4] | |
result = [] | |
def flatten_list(input_ele, list_obj=[]): | |
if isinstance(input_ele, list): | |
flatten_list(input_ele, list_obj) | |
else: | |
list_obj.append(input_ele) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment