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:
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:
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.
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://w3resource.com/python-exercises/tuple/python-tuple-exercise-15.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics