Skip to content

Instantly share code, notes, and snippets.

@Cediddi
Created September 9, 2016 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cediddi/4ab1dc713d37a6134a17cc8e17fe6989 to your computer and use it in GitHub Desktop.
Save Cediddi/4ab1dc713d37a6134a17cc8e17fe6989 to your computer and use it in GitHub Desktop.
This function takes a list and recursively changes all lists to tuples
def list2tuple(l):
"""This function takes a list and recursively changes all lists to tuples"""
rlist = []
for i in l:
if type(i) in (list, tuple, set):
rlist.append(l2t(i))
else:
rlist.append(i)
return tuple(rlist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment