tuples from lists
Thomas Guettler
pan-newsreader at thomas-guettler.de
Sun Mar 9 15:42:19 EST 2003
On Sun, 09 Mar 2003 21:12:34 +0100, Bob Roberts wrote:
> I have a list of lists of lists. How can I turn that into a tuple of
> tuples of tuples?
this recursive function should do it:
def list2tuple(mylist):
t=type(mylist)
if t==type([]):
new_list=[]
for item in mylist:
new_list.append(list2tuple(item))
return tuple(new_list)
else:
return mylist
print(list2tuple([[],[[],[]],[]]))
thomas
--
Thomas Guettler <guettli at thomas-guettler.de>
http://www.thomas-guettler.de
More information about the Python-list
mailing list