写函数,返回一个扑克牌列表,里面有52项,每一项是一个元组 例如:[(‘红心’,2),(‘草花’,2), …(‘黑桃,A

def list_poker():
#   先写一个数字的列表
    all_num = []
    for i in range(1,14):
        for j in range(1,5):
            if i == 1:
                i = "A"
                all_num.append(i)
            elif i == 11:
                i = "J"
                all_num.append(i)
            elif i == 12:
                i = "Q"
                all_num.append(i)
            elif i == 13:
                i = "K"
                all_num.append(i)
            else:
                all_num.append(i)
    print(all_num)

# 再写一个颜色的列表
    coul=["红心","草花","方块","黑桃"]
    all_coul =[]
    j = 0
    for j in range(1,14):
        for i in coul:
            all_coul.append(i)
    print(all_coul)

    all_list = list(zip(all_coul,all_num))
    print(all_list)
    return all_list
list_poker()

你可能感兴趣的:(写函数,返回一个扑克牌列表,里面有52项,每一项是一个元组 例如:[(‘红心’,2),(‘草花’,2), …(‘黑桃,A)