Q:

Write a Python function that takes a list of words and returns the longest word and the length of the longest one.

0

Write a Python function that takes a list of words and returns the longest word and the length of the longest one.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def find_longest_word(words_list):
    word_len = []
    for n in words_list:
        word_len.append((len(n), n))
    word_len.sort()
    return word_len[-1][0], word_len[-1][1]
result = find_longest_word(["PHP", "Exercises", "Backend"])
print("\nLongest word: ",result[1])
print("Length of the longest word: ",result[0])

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now