简介
在 Python 中,列表(list)可以包含其他列表作为元素。这被称为嵌套列表(nested list)。有时,我们可能需要将嵌套列表展平为单个列表。在这个挑战中,你将被要求编写一个函数,将列表的列表展平一次。
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
python(("Python")) -.-> python/BasicConceptsGroup(["Basic Concepts"])
python(("Python")) -.-> python/ControlFlowGroup(["Control Flow"])
python(("Python")) -.-> python/DataStructuresGroup(["Data Structures"])
python(("Python")) -.-> python/FunctionsGroup(["Functions"])
python/BasicConceptsGroup -.-> python/comments("Comments")
python/ControlFlowGroup -.-> python/for_loops("For Loops")
python/ControlFlowGroup -.-> python/list_comprehensions("List Comprehensions")
python/DataStructuresGroup -.-> python/lists("Lists")
python/DataStructuresGroup -.-> python/tuples("Tuples")
python/FunctionsGroup -.-> python/function_definition("Function Definition")
subgraph Lab Skills
python/comments -.-> lab-13641{{"展平列表"}}
python/for_loops -.-> lab-13641{{"展平列表"}}
python/list_comprehensions -.-> lab-13641{{"展平列表"}}
python/lists -.-> lab-13641{{"展平列表"}}
python/tuples -.-> lab-13641{{"展平列表"}}
python/function_definition -.-> lab-13641{{"展平列表"}}
end