求4.24选出一张牌如何解答

求4.24选出一张牌如何解答
不知道如何处理,Ace,Jack等字符串。
希望可以写出此题的解题代码。


回答:

import random

ranks = [str(n) for n in range(2, 11)]

ranks.extend(['Jack', 'Queen', 'King', 'Ace'])

suits = ['Spades','Diamonds','Clubs','Hearts']

cards = [

(rank, suit)

for suit in suits

for rank in ranks

]

pick = random.choice(cards)

print(f"The card you picked is the {pick[0]} of {pick[1]}")

以上是 求4.24选出一张牌如何解答 的全部内容, 来源链接: utcz.com/p/938126.html

回到顶部