0

Can anyone tell me how to write a program that displays all of the cards from a deck of playing cards? i set up two tuples, one with the
ranks and the other with the suits. I cant figure out how to make the Ace of spades - King of spades......combining parts of my tuples together.

[rank = (("A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K")) suit = (("c", "h", "s", "d")) card = ()]

Thanks

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Stefano Mtangoo
1

Two loops will do, or you can use a list comprehension:

rank = ("A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K")
suit = ("c", "h", "s", "d")

card = []
for r in rank:
    for s in suit:
        card.append(r+s)

card = tuple(card)
print(card)

"""
my result made pretty -->
('Ac', 'Ah', 'As', 'Ad', '2c', '2h', '2s', '2d', '3c', '3h', '3s', 
'3d', '4c', '4h', '4s', '4d', '5c', '5h', '5s', '5d', '6c', '6h', 
'6s', '6d', '7c', '7h', '7s', '7d', '8c', '8h', '8s', '8d', '9c', 
'9h', '9s', '9d', '10c', '10h', '10s', '10d', 'Jc', 'Jh', 'Js', 
'Jd', 'Qc', 'Qh', 'Qs', 'Qd', 'Kc', 'Kh', 'Ks', 'Kd')
"""
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.