“Cómo no listar una lista en Python” Código de respuesta

Python Cómo innecesar una lista anidada

# Basic syntax:
unnested_list = list(chain(*nested_list))
# Where chain comes from the itertools package and is useful for 
#	unnesting any iterables

# Example usage:
from itertools import chain
nested_list = [[1,2], [3,4]]
my_unnested_list = list(chain(*nested_list))
print(my_unnested_list)
--> [1, 2, 3, 4]
Charles-Alexandre Roy

Cómo no listar una lista en Python

a_list=["hello","there","little","kid",":)"]
not_a_list=" ".join(a_list)
print(not_a_list)
#==> "hello there little kid :)"
Shiny Seal

Respuestas similares a “Cómo no listar una lista en Python”

Preguntas similares a “Cómo no listar una lista en Python”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código