Q. Write a program as per following specification :

"Return the length of the shortest string in the tuple of a strings str_tuple.

Precondition : the tuple will contain at least one element."


You can understand by Watching video :-



Answer :-

tup = eval(input("Enter the string tuple = "))
short = tup [ 0 ]
for i in tup :
    if len(i) < len( short ) :
        short = i
print("Smallest string in tuple = ",short)

Output :-

Enter the string tuple = ("path","walla","portal","express","computer","python")
Smallest string in tuple =  path

>>>

Enter the string tuple = ("Python","C+++","Java","CSS")
Smallest string in tuple =  CSS

>>>

5 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Replies
    1. Please watch the video for clear explanation.

      Delete
  2. Wrong Program infact not just this but most of them are for here I will proof so here we need to find length but there is no mention about length in the program so basically wrong because it won't give the desired output

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post