Python Exercise: Find the length of a tuple
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.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics