Python:删除元素列表

时间:2018-12-13 11:13:16

标签: python list

在下面的列表中,我打算从每个列表中删除前三个元素:

x = [(0,1,2,3,5), (0,13,2,6,9), (0,7,8,42,3), (6,9,4,5,6)]
print(x)

预期的输出列表:

x = [(3,5), (6,9), (42,3), (5,6)]

我尝试过的事情:

#x.pop(0)  //that would remove the whole (0,1,2,3,5)
#x = [1: ]  //the would again eradicate (0,1,2,3,5)

1 个答案:

答案 0 :(得分:0)

您可以使用:

y= [i[3:] for i in x ]
[(3, 5), (6, 9), (42, 3), (5, 6)]