List -> Tuple
Chris Barker
chrishbarker at home.net
Wed Oct 31 13:25:34 EST 2001
Skip Montanaro wrote:
>
> Joseph> Is there a simple way to convert a list into a tuple, like a
> Joseph> built-in function for that?
> Try the tuple builtin:
>
> >>> l = [1,2,3]
> >>> tuple(l)
> (1, 2, 3)
> Joseph> Or is the easiest way to just
> Joseph> iterate through the list and append to a tuple?
By the way, that's not an option anyway, tuples are immutable, so you
can't append to them. You need to build them all at once.
-Chris
--
Christopher Barker,
Ph.D.
ChrisHBarker at home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------
More information about the Python-list
mailing list