将索引添加到新列表

Add index to a new list

我想追加从“my_list”到“item”的多个索引。
请参阅第 3 行代码,我想知道是否有一种 better/easier 方法可以一次将多个索引附加到我的新列表中#to my new list??

my_list = ['1970', '43', '18', '336', '0', '0', '0', '0', '41', '0', '', '4']
item_list = []
item_list.append(my_list[3])
print(item_list)

您可以使用 extend 并将其作为列表。

my_list = ['1970', '43', '18', '336', '0', '0', '0', '0', '41', '0', '', '4']
item_list = []
item_list.extend([my_list[3], my_list[2], my_list[6]])
print(item_list)