Robotics & Artificial Intelligence
Write a program to print the longest word in the given list of words.
Python Control Flow
1 Like
Answer
words = ["apple", "banana", "grapes", "watermelon", "kiwi"]
longest = words[0]
for w in words:
if len(w) > len(longest):
longest = w
print("The longest word is:", longest)Output
The longest word is: watermelon
Answered By
1 Like
Related Questions
Write a python program to print a pyramid using 'for' loop.
Write a program to store marks of your class students and show their percentage.
Write a program to implement a simple shopping cart system. In it user can add items, remove items, view the cart, and calculate the total cost.
Write a program that inputs two tuples and creates a third one that contains all the elements of the first tuple followed by all the elements of the second tuple.