, asked
Views : 6

How to create a tuple from a string and a list of strings in Python?

How to create a tuple from a string and a list of strings in Python?                    

1 Answer
Malhar Lathkar

The built-in function tuple() converts a Python string into tuple of individual characters. It also turns a list object into a tuple.

>>> tuple("TutorialsPoint")
('T', 'u', 't', 'o', 'r', 'i', 'a', 'l', 's', 'P', 'o', 'i', 'n', 't')
>>> L1=[45, 32, 100, 10, 24, 56]
>>> tuple(L1)
(45, 32, 100, 10, 24, 56)

Advertisements
Related Questions