BaşlayınÜcretsiz Başlayın

Combining iterable objects

You are given the list wlist that contains lists of different words. Your task is to create a new iterable object, where each element represents a tuple. Each tuple should contain a list from the wlist, the length of this list, and the longest word within this list. If there is ambiguity in choosing the longest word, the word with the lowest index in the considered list should be taken into account. For example, given the list

[
    ['dog', 'pigeon'],
    ['cat', 'wolf', 'seal']
]

the resulting tuples will be:
(['dog', 'pigeon'], 2, 'pigeon')
and
(['cat', 'wolf', 'seal'], 3, 'wolf')

Bu egzersiz

Practicing Coding Interview Questions in Python

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Define a function searching for the longest word
def get_longest_word(words):
    longest_word = ''
    for word in words:
        if ____:
            ____ = ____
    return longest_word
Kodu Düzenle ve Çalıştır