w3resource

Python Exercise: Find the length of a tuple

Python tuple: Exercise-15 with Solution

Write a Python program to find the length of a tuple.

Visual Presentation:

Python Tuple: Find the length of a tuple.

Sample Solution:

Python Code:

# Create a tuple by converting the string "w3resource" into a tuple
tuplex = tuple("w3resource")
# Print the contents of the 'tuplex' tuple
print(tuplex)

# Use the 'len()' function to determine the length of the 'tuplex' tuple
print(len(tuplex)) 

Sample Output:

('w', '3', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e')                                                            
10   

Flowchart:

Flowchart: Find the length of a tuple

Python Code Editor:

Previous: Write a Python program to find the index of an item of a tuple.
Next: Write a Python program to convert a tuple to a dictionary.

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-15.php