w3resource

Python Exercise: Tuple to a string

Python tuple: Exercise-6 with Solution

Write a Python program to convert a tuple to a string.

Pictorial Presentation:

Python Tuple: Tuple to a string.

Sample Solution:

Python Code:

# Create a tuple containing individual characters
tup = ('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's')
# Use the 'join' method to concatenate the characters in the tuple without any spaces and create a single string
str = ''.join(tup)
# Print the resulting string
print(str)

Sample Output:

exercises 

Flowchart:

Flowchart: Get an item of a tuple

Python Code Editor:

Previous: Write a Python program to add an item in a tuple.
Next: Write a Python program to get the 4th element and 4th element from last of a tuple.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python-exercises/tuple/python-tuple-exercise-6.php