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

2 Likes


Related Questions