Python 3.x 是否有一个内置方法可以为数组中的特定索引丢弃元素的一部分?

Python 3.x 是否有一个内置方法可以为数组中的特定索引丢弃元素的一部分?,python-3.x,Python 3.x,我正在创建这个游戏,我需要比较玩家1和玩家2的卡片,它们存储在一个数组中 每个卡代表数组中的一个元素,由一个值(1-30)和一种颜色(红色、黑色或黄色)组成 我的任务是分别比较每张卡的颜色和每张卡的价值——但我应该使用什么内置方法来只关注元素的颜色或价值 这是我的密码: colours = ['RED','BLACK','YELLOW'] deck = [(random.randint(1,31),random.choice(colours)) for _ in range(30)] rando

我正在创建这个游戏,我需要比较玩家1和玩家2的卡片,它们存储在一个数组中

每个卡代表数组中的一个元素,由一个值(1-30)和一种颜色(红色、黑色或黄色)组成

我的任务是分别比较每张卡的颜色和每张卡的价值——但我应该使用什么内置方法来只关注元素的颜色或价值

这是我的密码:

colours = ['RED','BLACK','YELLOW']
deck = [(random.randint(1,31),random.choice(colours)) for _ in range(30)]
random.shuffle(deck) 

def Player1_Cards(deck):
    return deck[:15]   #Player1 takes the first 15 cards from the array deck     
def Player2_Cards(deck): #Player2 takes the last 15 cards from the array deck
    return deck[15:]

print('Player 1`s cards are :',Player1_Cards(deck))
print('Player 2`s cards are :',Player2_Cards(deck))

#Here's what the array of Player1's Cards looks like:
[(5, 'BLACK'), (4, 'RED'), (31, 'YELLOW'), (27, 'RED'), (19, 'RED'), (6, 'YELLOW'), (11, 'YELLOW'), (17, 'BLACK'), (15, 'RED'), (20, 'BLACK'), (13, 'BLACK'), (9, 'RED'), (30, 'YELLOW'), (9, 'YELLOW'), (20, 'YELLOW')]

你想做什么样的比较?无论你想做什么比较,我建议你把它移到
numpy
(以及随机变量的生成)。