converting a list into a tuple?

Fredrik Lundh fredrik at pythonware.com
Thu May 24 07:09:29 EDT 2001


Harvest Moon wrote:
> how do i convert
>
> mylist = ["foo", "bar"]
>
> into
>
> mytuple = ("foo", "bar")

how about:

    mytuple = tuple(mylist)

(use list(mytuple) to go the other way)

Cheers /F





More information about the Python-list mailing list