It's a question from Python list

Asked 2 years ago, Updated 2 years ago, 46 views

I'd like to take out the values I want from the list in the form of a list. For example, x=[[1,2,3,4],[10,20,30,40],[100,110,120,130]] What should I do if I want to get the output value [1,30,110] by taking out the output value I think I can use the overlapping for statement, but it's hard to do it.

x=[[1,2,3,4],[10,20,30,40],[100,110,120,130]]

Output value: [1,30,110]

python list

2022-09-22 13:56

1 Answers

I think it was difficult because it was an overlapping list.

It's a simple approach.

x=[[1,2,3,4],[10,20,30,40],[100,110,120,130]]

[x[0][0], x[1][2], x[2][1]]
[1, 30, 110]


2022-09-22 13:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.