from random import choice as rc
print("LET'S PLAY POKER")
while True:
a = raw_input("Do you want to play poker? y/n: ")
if a == 'y':
cards = ['2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', '10h', 'Jh', 'Qh', 'Kh', 'Ah', '2d', '3d', '4d', '5d', '6d', '7d', '8d', '9d', '10d', 'Jd', 'Qd', 'Kd', 'Ad', '2c', '3c', '4c', '5c', '6c', '7c', '8c', '9c', '10c', 'Jc', 'Qc', 'Kc', 'Ac', '2s', '3s', '4s', '5s', '6s', '7s', '8s', '9s', '10s', 'Js', 'Qs', 'Ks', 'As']
player = []
player.append(rc(cards))
player.append(rc(cards))
print("You have {0}".format(player))
flop = []
flop.append(rc(cards))
flop.append(rc(cards))
flop.append(rc(cards))
print("Dealing the flop: {0} ".format(flop))
turn = []
turn.append(rc(cards))
print("Dealing the turn: {0} ".format(turn))
river = []
river.append(rc(cards))
print("Dealing the river: {0} ".format(river))
print("The board is {0} {1} {2} ".format(flop, turn, river))
computer = []
computer.append(rc(cards))
computer.append(rc(cards))
print("Computer has {0} ".format(computer))
print("Guess who wins")
elif a == 'n':
print("I gues you are to tired of losing")
break
else:
print("Invalid command try again")
print("Done")
raw_input("Press<enter>to exit")
What I don't like is that it is possible the same card to be dealt to the player and also appear on the board. How can I make my program in such a way that after i take an object from the 'cards' list it removes itself from the list and wont be available as random choice for the 'flop' list for example.
Also tell me what you think for my program. I've been learning python for a month and this code is the best come up with.


Sign In
Create Account


Back to top









