Q. Write a short python code segment that print the longest word in the list of the word.


You can understand by Watching video :-



Answer :-

lst = eval(input ("Enter the list = "))
long =  len ( lst [ 0 ])

for i in lst :
    if long <= len ( i ):
        long = len ( i )
        word = i

print ("longest word in list = " , word )

Output :-

Enter the list = ["Path","Walla","Portal","Express"]
longest word in list =  Express

>>> 

Enter the list = ["C++","Python","Java","CSS"]
longest word in list =  Python

>>>


Post a Comment

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

Previous Post Next Post