“doppelt für in Python” Code-Antworten

doppelt für in Python

something = [element for subsequence in sequence for element in subsequence]

This is easy to understand if we break it into parts: [A for B in C]

- A is the item that will be in the resulting list
- B is each item in the collection C
- C is the collection itself.
John D'oh

Doppel für in Loop Python

#code to print all atomic members of a list into a single list
#eg convert [[1,2,3], [4,5,6], [7,8,9,10]] to 
l0 = [[1,2,3], [4,5,6], [7,8,9,10]]

flat = [l2 for l1 in l0 for l2 in l1]
#prints out:
#[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Real Rhinoceros

Ähnliche Antworten wie “doppelt für in Python”

Fragen ähnlich wie “doppelt für in Python”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen