0

This is what I currently have:

[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]

This is what my expected outcome looks like:

[[1,3],[5,7],[9,11],[13,15]]

2 Answers2

0

You can use unpacking:

s = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
new_data = [[a, b] for a, _, b, c in s]

Output:

[[1, 3], [5, 7], [9, 11], [13, 15]]
Ajax1234
  • 69,937
  • 8
  • 61
  • 102
0
t = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
x = []

for v in t:
    x.append([v[0], v[2]])
Mitch
  • 3,342
  • 2
  • 21
  • 31
  • While this code may answer the question, providing additional context regarding **how** and/or **why** it solves the problem would improve the answer's long-term value. – Alexander Apr 06 '18 at 03:35