Skip to content

Instantly share code, notes, and snippets.

@sreevidyavutukuru
Created July 15, 2017 04:38
Show Gist options
  • Save sreevidyavutukuru/470911c10858a93b2f88bb96cd07b56d to your computer and use it in GitHub Desktop.
Save sreevidyavutukuru/470911c10858a93b2f88bb96cd07b56d to your computer and use it in GitHub Desktop.
list1= ['a','b',['c','d',['e','f']],'j',['k','l']]
def print_flat(list1,appendStr=''):
if isinstance(list1, str):
print appendStr + ' ' + list1
else:
for i,val in enumerate(list1):
print_flat(val, appendStr + (lambda x: "." if x != "" else "")(appendStr) + str(i))
print_flat(list1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment