List -> Tuple

Skip Montanaro skip at pobox.com
Wed Oct 31 11:36:53 EST 2001


    Joseph> Is there a simple way to convert a list into a tuple, like a
    Joseph> built-in function for that? Or is the easiest way to just
    Joseph> iterate through the list and append to a tuple?

Try the tuple builtin:

    >>> l = [1,2,3]
    >>> tuple(l)
    (1, 2, 3)

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list