The tuple constructor

Should you need to create a tuple from an existing collection object, such as a list, you can use the tuple() constructor. Here we create a tuple from a list:

>>> tuple([561, 1105, 1729, 2465])
(561, 1105, 1729, 2465)

And here we create a tuple containing the characters of a string:

>>> tuple("Carmichael")
('C', 'a', 'r', 'm', 'i', 'c', 'h', 'a', 'e', 'l')
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset