Convert tuple to string Python | Example code

Use str join() method or for loop to Convert tuple to string Python. We will convert a tuple to a string concatenates each string in the tuple into a single string.

Convert tuple to string Python exmaple

Simple example code.

Use str join() funciton

Call join(iterable) function with “” as str to convert a tuple iterable to a string.

a_tuple = ("A", "B", "C")

res = "".join(a_tuple)

print(res)

Output:

Convert tuple to string Python

Using simple for loop

First, create an empty string and use a for loop iterate through the elements of the tuple with adding each element to the empty string.

tup = ("A", "B", "C")

str1 = ''
for item in tup:
    str1 = str1 + item

print(str1)

Output: ABC

Do comment if you have any doubts and suggestions on this Python tuple string topic.

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.