This post will discuss how to convert a tuple to a string Python.

1. Using join() function

The idea is to use the built-in function str.join, which returns the concatenation of the strings in an iterable.

Download  Run Code

 
If you need a comma-separated string or a string separated with some other delimiter, you can use the following code:

Download  Run Code

 
This will raise a TypeError for any non-string values in the tuple. For example, it fails when the tuple contains numbers. To handle this, you can use the map function:

Download  Run Code

2. Using reduce operation

Another option is to perform a reduction operation using the functools.reduce function.

Download  Run Code

 
This will raise a TypeError for any non-string values in the tuple. To handle this, you can use the string constructor:

Download  Run Code

That’s all about converting a tuple to a string Python.