Skip to content

Instantly share code, notes, and snippets.

@ViktorovEugene
Created November 8, 2016 18:29
Show Gist options
  • Save ViktorovEugene/51a60ac0b71e382496a8ed41e1f13b72 to your computer and use it in GitHub Desktop.
Save ViktorovEugene/51a60ac0b71e382496a8ed41e1f13b72 to your computer and use it in GitHub Desktop.
Utility function that accepts list with nested structure and returns flat list.
def flatten_list(list_to_flatten):
flat_list = []
for item in list_to_flatten:
if type(item) != list:
flat_list.append(item)
else:
flat_list += flatten_list(item)
return flat_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment