将二维列表连接到新列表中

时间:2019-03-03 10:28:39

标签: python

我有这样的列表:

  

My_list = [[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15],[16,17,18,19 ,20]]

我要这样列出一个新列表:

  

new_list =   [[1,2,3,9,10],[4,5,6,7,8],[11,12,13,19,20],[14,15,16,17,18]] < / p>

索引0的前一半+索引1的后一半以及相反的含义,但是我不知道该怎么做。

类似这样的东西:

  

new_list [1] [:3] + new_list [2] [2:]

我该怎么办?

2 个答案:

答案 0 :(得分:1)

这是您的问题的代码。

$this->app->bind('MyService', function ($app) {
   return new MyService(
      $app->make('Carbon'),
      $app->makeWith('SendGrid', ['apiKey' => '123'])
   )
});

答案 1 :(得分:0)

你是这个意思吗?

My_list = [[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15],[16,17,18,19,20]] new_list=My_list[0][:3]+My_list[1][3:])

相关问题