Created
September 9, 2016 11:59
-
-
Save Cediddi/4ab1dc713d37a6134a17cc8e17fe6989 to your computer and use it in GitHub Desktop.
This function takes a list and recursively changes all lists to tuples
This file contains hidden or 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
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