In [68]:
import random

print("Welcome to the Poker Game!")#Welcoming message.
print("Here are the rules.")#Telling you the rules on how to play this game.
print("The deck is divided evenly to each player, with each player receiving 13 cards.")#It is telling you how the deck is divided evenly and how much each player get for the cards.
print("The cards will be flipped for the playeres and the player with the higher card takes both cards.")#Whenever gets the higher card takes both of the cards. 
print("If the cards are the same rank, it is War. Each player turns up one card face down and one card face up.The player with the higher card takes both piles, if they are the same rank,each players places another card face down and turns the other face down card up. It will continue until the winner of that pile is determined.")#It is just saying if the card is the same, then it is war whoever get the higher card wins, but if it is the same card, then you will keep on repeating the process.

player1 = input("Player 1, please enter your name:")#It is going to ask you to write your name.
player2 = input("Player 2, please enter your name:")#It is going to ask you to write your name.

def deal_cards():#Distributing the cards to each of the player.
    suits = ['Hearts','Diamonds', 'Clubs', 'Spades']#Create a deck of 52 cards.
    ranks = ['Ace', '2','3','4','5','6','7','8','9','10','Jack', 'Queen','King']#This is how many ranks the cards have. 
    deck = [(rank, suit) for suit in suits for rank in ranks]#It refers to a list that represents a deck of cards that are being played with.              
    
    random.shuffle(deck)#The deck is being shuffled.
    hand = deck[:13]#Selecting the first 13 elements from the deck list and you are assigning them to a new list that is called 'Hand'.
    return hand#Giving back. 
    
def play_game():#Playing the game.
    print(f"{player1}, it's your turn.")#It's your turn to play. 
hand1 = deal_cards()#Player1 is to deal the cards.
print(f"{player1}, your hand;{hand1}")#How many cards player1 is holding.
    
print(f"{player2}, it's your turn.")#It's your turn to play.
hand2 = deal_cards()#Player2 is to deal the cards.
print(f"{player2}, your hand;{hand2}")#How many cards player2 is holding.
    
discard_count = int(input("How many cards would you like to discard(1-4)?"))#It is asking you how many out of four cards would you like to get rid of.
if discard_count > 4:#There are four or more cards that needs to be discarded. 
        discard_count = 4#Their are four items that needs to be discarded,
        
for i in range(discard_count):#It is used to create a loop.
    card = input("Enter the card you want to discard:")#It is asking you to take out the cards you want to get rid of.
    
print("New cards have been dealt with.")#You have recevied a new deck of cards.
 
print(f"\{player1}, here is your final hand:{hand1}")#Player one will get their final deck of cards.
print(f"\{player2}, here is your final hand:{hand2}")#Player one will get their final deck of cards.

while True:#A loop that is continues indefinitely.
        play_again = True#Correct.
    play_again_input = input("Do you want to play again? (Y/N)")#It is asking you if you want to play the game again.
    else play_again_input.lower() !="yes":#You are choosing to play agaib.
        play_again = False#Incorrect 
        break#The game is over.
print("Have a nice day!!!")#It is telling you to have a nice day
    
Welcome to the Poker Game!
Here are the rules.
The deck is divided evenly to each player, with each player receiving 13 cards.
The cards will be flipped for the playeres and the player with the higher card takes both cards.
If the cards are the same rank, it is War. Each player turns up one card face down and one card face up.The player with the higher card takes both piles, if they are the same rank,each players places another card face down and turns the other face down card up. It will continue until the winner of that pile is determined.
Player 1, please enter your name:ang
Player 2, please enter your name:ang
ang, your hand;[('10', 'Clubs'), ('10', 'Hearts'), ('Queen', 'Spades'), ('4', 'Spades'), ('8', 'Clubs'), ('Queen', 'Hearts'), ('Queen', 'Clubs'), ('3', 'Clubs'), ('King', 'Hearts'), ('Ace', 'Hearts'), ('10', 'Spades'), ('2', 'Clubs'), ('Ace', 'Clubs')]
ang, it's your turn.
ang, your hand;[('3', 'Spades'), ('10', 'Hearts'), ('6', 'Hearts'), ('10', 'Clubs'), ('4', 'Hearts'), ('5', 'Diamonds'), ('3', 'Hearts'), ('King', 'Diamonds'), ('Queen', 'Diamonds'), ('9', 'Diamonds'), ('7', 'Clubs'), ('4', 'Diamonds'), ('Ace', 'Spades')]
How many cards would you like to discard(1-4)?2
Enter the card you want to discard:diamond
Enter the card you want to discard:queen
New cards have been dealt with.
\ang, here is your final hand:[('10', 'Clubs'), ('10', 'Hearts'), ('Queen', 'Spades'), ('4', 'Spades'), ('8', 'Clubs'), ('Queen', 'Hearts'), ('Queen', 'Clubs'), ('3', 'Clubs'), ('King', 'Hearts'), ('Ace', 'Hearts'), ('10', 'Spades'), ('2', 'Clubs'), ('Ace', 'Clubs')]
\ang, here is your final hand:[('3', 'Spades'), ('10', 'Hearts'), ('6', 'Hearts'), ('10', 'Clubs'), ('4', 'Hearts'), ('5', 'Diamonds'), ('3', 'Hearts'), ('King', 'Diamonds'), ('Queen', 'Diamonds'), ('9', 'Diamonds'), ('7', 'Clubs'), ('4', 'Diamonds'), ('Ace', 'Spades')]
Do you want to play again? (Y/N)n
Have a nice day!!!
In [ ]: