Skip to content

Convert tuple to string Python | Example code

  • by

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 the 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 to iterate through the elements of the tuple by 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 or suggestions on this Python tuple string topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

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

Leave a Reply

Your email address will not be published. Required fields are marked *

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