CBSE Class 11 Computer Science Question 106 of 114

Tuples — Question 9

Back to all questions
9
Question

Question 8

Write a program as per following specification :

"'Return the length of the shortest string in the tuple of strings str_tuple.
Precondition: the tuple will contain at least one element."'

Solution
str_tuple = ("computer science with python" ,"Hello Python" ,"Hello World" ,"Tuples")
shortest_str = min(str_tuple)
shortest_str_len = len(shortest_str)
print("The length of shortest string in the tuple is:", shortest_str_len)
Output
The length of shortest string in the tuple is: 12
Answer