Oct-22-2017, 04:27 AM
Here is what I have (just playing around making a black jack game for a bit of Python practice):
How would I be able to find the name of the card1 and card2 and how would I be able to print them?
from random import *
def main():
aceHearts, aceSpades, aceDiamonds, aceClubs = 11, 11, 11, 11
kingHearts, kingSpades, kingDiamonds, kingClubs = 10, 10, 10, 10
queenHearts, queenSpades, queenDiamonds, queenClubs = 10, 10, 10, 10
jackHearts, jackSpades, jackDiamonds, jackClubs = 10,10, 10, 10
tenHearts, tenSpades, tenDiamonds, tenClubs = 10, 10, 10, 10
nineHearts, nineSpades, nineDiamonds, nineClubs = 9, 9, 9, 9
eightHearts, eightSpades, eightDiamonds, eightClubs = 8, 8, 8, 8
sevenHearts, sevenSpades, sevenDiamonds, sevenClubs = 7, 7, 7, 7
sixHearts, sixSpades, sixDiamonds, sixClubs = 6, 6, 6, 6
fiveHearts, fiveSpades, fiveDiamonds, fiveClubs = 5, 5, 5, 5
fourHearts, fourSpades, fourDiamonds, fourClubs = 4, 4, 4, 4
threeHearts, threeSpades, threeDiamonds, threeClubs = 3, 3, 3, 3
twoHearts, twoSpades, twoDiamonds, twoClubs = 2, 2, 2, 2
deck = [
aceHearts, aceSpades, aceDiamonds, aceClubs,
kingHearts, kingSpades, kingDiamonds, kingClubs,
queenHearts, queenSpades, queenDiamonds, queenClubs,
jackHearts, jackSpades, jackDiamonds, jackClubs,
tenHearts, tenSpades, tenDiamonds, tenClubs,
nineHearts, nineSpades, nineDiamonds, nineClubs,
eightHearts, eightSpades, eightDiamonds, eightClubs,
sevenHearts, sevenSpades, sevenDiamonds, sevenClubs,
sixHearts, sixSpades, sixDiamonds, sixClubs,
fiveHearts, fiveSpades, fiveDiamonds, fiveClubs,
fourHearts, fourSpades, fourDiamonds, fourClubs,
threeHearts, threeSpades, threeDiamonds, threeClubs,
twoHearts, twoSpades, twoDiamonds, twoClubs
]
card1, card2 = sample(deck, 2)Yes I understand there is probably a better way of doing this, but like I said I am just practicing as a new student of Python (and coding overall). How would I be able to find the name of the card1 and card2 and how would I be able to print them?
