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



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)


Updated on: 2020-02-20T11:22:49+05:30

224 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements