fork(10) download
  1. data = [[1, 2], [3, 4], [5, 6]]
  2. output = []
  3. for each_list in data:
  4. for element in each_list:
  5. output.append(element)
  6. print(output)
  7. # Out: [1, 2, 3, 4, 5, 6]
  8.  
  9. data = [[1, 2], [3, 4], [5, 6]]
  10. output = [element for each_list in data for element in each_list]
  11. print(output)
  12. # Out: [1, 2, 3, 4, 5, 6]
Success #stdin #stdout 0.02s 9936KB
stdin
Standard input is empty
stdout
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]