Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created March 13, 2010 14:34
Show Gist options
  • Save lxneng/331343 to your computer and use it in GitHub Desktop.
Save lxneng/331343 to your computer and use it in GitHub Desktop.
Convert list of lists to delimited string
In [1]: lists = [['dog', 1], ['cat', 2, 'a'], ['rat', 3, 4], ['bat', 5]]
In [2]: result = "\n".join("\t".join(map(str,l)) for l in lists)
In [3]: result
Out[3]: 'dog\t1\ncat\t2\ta\nrat\t3\t4\nbat\t5'
In [4]: print(result)
dog 1
cat 2 a
rat 3 4
bat 5
In [5]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment