“Lista de classificação de strings por comprimento python” Respostas de código

Classifique uma lista por comprimento Python

#Input
def sort():
	lst = [orange, ant, phone, banana, notebook)
	lst2 = sorted(lst, key=len)
    return lst2
           
#Output : [ant, phone, banana, orange, notebook)
Distinct Dingo

Lista de classificação de strings por comprimento python

# Read the input

input_list = [orange, ant, phone, banana, notebook]

# Use the sorted function on the input_list with the key argument set as 'len'
output_list = sorted(input_list, key = len)

# Output the sorted list
print(output_list)
Girish Pal

Respostas semelhantes a “Lista de classificação de strings por comprimento python”

Perguntas semelhantes a “Lista de classificação de strings por comprimento python”

Procure respostas de código populares por idioma

Procurar outros idiomas de código