Generation

generate functionTue, 18 Apr 2023

Crea una función que reciba una frase y devuelva un diccionario con las palabras que contiene y su longitud.

def word_length(text): word_list = text.split() length_dict = {} for word in word_list: length_dict[word] = len(word) return length_dict word_length("I am the one who knocks")

Questions about programming?Chat with your personal AI assistant