w3resource

Python Exercise: Tuple to a string


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.



Follow us on Facebook and Twitter for latest update.