How can I convert Python strings into tuple?

PythonServer Side ProgrammingProgramming

Python’s built-in function tuple() converts any sequence object to tuple. If it is a string, each character is treated as a string and inserted in tuple separated by commas.

>>> string="Tutorialspoint"
>>> tuple(string)
('T', 'u', 't', 'o', 'r', 'i', 'a', 'l', 's', 'p', 'o', 'i', 'n', 't')

Any non-sequence object as argument results in TypeError.

Updated on 24-Feb-2020 10:06:34