Find the Longest Word in a Dictionary
Advanced
Find the Longest Word in a Dictionary
Hey there, young coders! Here's a fun and exciting challenge for you. Imagine you have a little dictionary (just a list of words). Your mission, should you choose to accept it, is to find the longest word in this list. Sounds cool, right?
You will create a function that returns the longest word from a given list of words. If there are multiple words of the same maximum length, return the one that appears first in the list.
Here's a sneak peek on how it should work:
find_longest_word(['cat', 'elephant', 'tiger']) # Should return: 'elephant' find_longest_word(['apple', 'banana', 'cherry', 'date']) # Should return: 'banana' find_longest_word(['a', 'ab', 'abc', 'abcd']) # Should return: 'abcd'
Can you write this magical function? Let's get coding and find that longest word!
Inputs
Arg 1:
["cat","elephant","tiger"]Expected Output
"elephant"Actual Output