Converting string to tuple without splitting characters

You can just do (a,). No need to use a function. (Note that the comma is necessary.)

Essentially, tuple(a) means to make a tuple of the contents of a, not a tuple consisting of just a itself. The “contents” of a string (what you get when you iterate over it) are its characters, which is why it is split into characters.

Leave a Comment