Trying to make a card game [on hold]Blackjack casino gameOptimizing “Poker hands” challenge...

We are very unlucky in my court

Solubility of a tribasic weak acid

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Does Windows 10's telemetry include sending *.doc files if Word crashed?

Would a National Army of mercenaries be a feasible idea?

Does Improved Divine Strike trigger when a paladin makes an unarmed strike?

Why does a metal block make a shrill sound but not a wooden block upon hammering?

How to prevent users from executing commands through browser URL

What is the lore-based reason that the Spectator has the Create Food and Water trait, instead of simply not requiring food and water?

Difference between two similar commands to activate a Python venv

Contest math problem about crossing out numbers in the table

Can a hotel cancel a confirmed reservation?

Why exactly do action photographers need high fps burst cameras?

Avoiding morning and evening handshakes

Word or phrase for showing great skill at something without formal training in it

Magento 2 : Call Helper Without Using __construct in Own Module

Why would the Pakistan airspace closure cancel flights not headed to Pakistan itself?

What's a good word to describe a public place that looks like it wouldn't be rough?

Calculate Contact age in a Drupal view

If I delete my router's history can my ISP still provide it to my parents?

What is this metal M-shaped device for?

Explain the objections to these measures against human trafficking

Guns against regular people

Removing c-style comments with sed



Trying to make a card game [on hold]


Blackjack casino gameOptimizing “Poker hands” challenge solutionProject Euler - Problem 54: testing poker handsPython implementation of snapDesign Tic tac toe gameSimulate a simplified version of Exploding Kittens in PythonDynamic Programming solution for one pile nim game450 line Python card gamePython card gamePython Text-based Card Game













-2












$begingroup$


I'm using python 3.6 and I am trying to make a card game. I'm trying to make it display the winner of the game and move the two cards that have been played into a new "winners list" however I am pretty new to programming and I just can't seem to make the comparing car section work. The game should compare player 1 and player 2's cards and the winner should receive both cards. inicially the colour are compare d and if they are the same the value is compared. The colour parameters are listed in the code Any improvements I can make to improve my program and some help as for how to make it work would be greatly appreciated. specifically, they are of the program labelled: #definition of the rule and comparing the cards. it just endlessly print player 2 wins.



import itertools
import random
Winner = False
finished = False
vals = ['1','2', '3', '4', '5', '6', '7', '8', '9', '10']
suits = ['Yellows', 'Reds', 'Blacks']

deck = list(itertools.product(vals, suits))

random.shuffle(deck)

for val, suit in deck:
print('%s of %s' % (val, suit))



player1card = deck[0:len(deck)//2]
player2card = deck[len(deck)//2:]
print("this is player 1",player1card)
print("this is Player 2 ",player2card)
#winning list
P1_Win = []
P2_Win = []
#still need to work on the scoring
player1_score = 0
player2_score = 0

while len(deck) > 0:

if Winner == True:
player1card[0].append(P1_Win)
player2card[0].append(P1_win)
#definition of the rule and comparing the cards
if player1card[0][1] == "Blacks" and player2card[0][1] == "Blacks":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Reds" and player2card[0][1] == "Reds":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Yellows" and player2card[0][1] == "Yellows":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Blacks" and player2card[0][1] == "Yellow":
Winner == True
print("Player 1 wins")

if player1card[0][1] == "Reds" and player2card[0][1] == "Blacks":
Winner == True
print("Player 1 wins")

if player1card[0][1] == "Yellows" and player2card[0][1] == "Reds":
Winner == True
print("Player 1 wins")
else:
player1card.append(P2_Win)
player2card.append(P2_Win)
print("Player 2 wins")









share|improve this question







New contributor




Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as off-topic by 200_success, AJNeufeld, Sᴀᴍ Onᴇᴌᴀ, Simon Forsberg 2 days ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, AJNeufeld, Sᴀᴍ Onᴇᴌᴀ, Simon Forsberg

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 1




    $begingroup$
    Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..." When you have fixed the code, please edit your post to include the working code and it can be reviewed."
    $endgroup$
    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago










  • $begingroup$
    For reviewers - cross post from SO
    $endgroup$
    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago
















-2












$begingroup$


I'm using python 3.6 and I am trying to make a card game. I'm trying to make it display the winner of the game and move the two cards that have been played into a new "winners list" however I am pretty new to programming and I just can't seem to make the comparing car section work. The game should compare player 1 and player 2's cards and the winner should receive both cards. inicially the colour are compare d and if they are the same the value is compared. The colour parameters are listed in the code Any improvements I can make to improve my program and some help as for how to make it work would be greatly appreciated. specifically, they are of the program labelled: #definition of the rule and comparing the cards. it just endlessly print player 2 wins.



import itertools
import random
Winner = False
finished = False
vals = ['1','2', '3', '4', '5', '6', '7', '8', '9', '10']
suits = ['Yellows', 'Reds', 'Blacks']

deck = list(itertools.product(vals, suits))

random.shuffle(deck)

for val, suit in deck:
print('%s of %s' % (val, suit))



player1card = deck[0:len(deck)//2]
player2card = deck[len(deck)//2:]
print("this is player 1",player1card)
print("this is Player 2 ",player2card)
#winning list
P1_Win = []
P2_Win = []
#still need to work on the scoring
player1_score = 0
player2_score = 0

while len(deck) > 0:

if Winner == True:
player1card[0].append(P1_Win)
player2card[0].append(P1_win)
#definition of the rule and comparing the cards
if player1card[0][1] == "Blacks" and player2card[0][1] == "Blacks":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Reds" and player2card[0][1] == "Reds":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Yellows" and player2card[0][1] == "Yellows":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Blacks" and player2card[0][1] == "Yellow":
Winner == True
print("Player 1 wins")

if player1card[0][1] == "Reds" and player2card[0][1] == "Blacks":
Winner == True
print("Player 1 wins")

if player1card[0][1] == "Yellows" and player2card[0][1] == "Reds":
Winner == True
print("Player 1 wins")
else:
player1card.append(P2_Win)
player2card.append(P2_Win)
print("Player 2 wins")









share|improve this question







New contributor




Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as off-topic by 200_success, AJNeufeld, Sᴀᴍ Onᴇᴌᴀ, Simon Forsberg 2 days ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, AJNeufeld, Sᴀᴍ Onᴇᴌᴀ, Simon Forsberg

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 1




    $begingroup$
    Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..." When you have fixed the code, please edit your post to include the working code and it can be reviewed."
    $endgroup$
    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago










  • $begingroup$
    For reviewers - cross post from SO
    $endgroup$
    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago














-2












-2








-2





$begingroup$


I'm using python 3.6 and I am trying to make a card game. I'm trying to make it display the winner of the game and move the two cards that have been played into a new "winners list" however I am pretty new to programming and I just can't seem to make the comparing car section work. The game should compare player 1 and player 2's cards and the winner should receive both cards. inicially the colour are compare d and if they are the same the value is compared. The colour parameters are listed in the code Any improvements I can make to improve my program and some help as for how to make it work would be greatly appreciated. specifically, they are of the program labelled: #definition of the rule and comparing the cards. it just endlessly print player 2 wins.



import itertools
import random
Winner = False
finished = False
vals = ['1','2', '3', '4', '5', '6', '7', '8', '9', '10']
suits = ['Yellows', 'Reds', 'Blacks']

deck = list(itertools.product(vals, suits))

random.shuffle(deck)

for val, suit in deck:
print('%s of %s' % (val, suit))



player1card = deck[0:len(deck)//2]
player2card = deck[len(deck)//2:]
print("this is player 1",player1card)
print("this is Player 2 ",player2card)
#winning list
P1_Win = []
P2_Win = []
#still need to work on the scoring
player1_score = 0
player2_score = 0

while len(deck) > 0:

if Winner == True:
player1card[0].append(P1_Win)
player2card[0].append(P1_win)
#definition of the rule and comparing the cards
if player1card[0][1] == "Blacks" and player2card[0][1] == "Blacks":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Reds" and player2card[0][1] == "Reds":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Yellows" and player2card[0][1] == "Yellows":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Blacks" and player2card[0][1] == "Yellow":
Winner == True
print("Player 1 wins")

if player1card[0][1] == "Reds" and player2card[0][1] == "Blacks":
Winner == True
print("Player 1 wins")

if player1card[0][1] == "Yellows" and player2card[0][1] == "Reds":
Winner == True
print("Player 1 wins")
else:
player1card.append(P2_Win)
player2card.append(P2_Win)
print("Player 2 wins")









share|improve this question







New contributor




Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




I'm using python 3.6 and I am trying to make a card game. I'm trying to make it display the winner of the game and move the two cards that have been played into a new "winners list" however I am pretty new to programming and I just can't seem to make the comparing car section work. The game should compare player 1 and player 2's cards and the winner should receive both cards. inicially the colour are compare d and if they are the same the value is compared. The colour parameters are listed in the code Any improvements I can make to improve my program and some help as for how to make it work would be greatly appreciated. specifically, they are of the program labelled: #definition of the rule and comparing the cards. it just endlessly print player 2 wins.



import itertools
import random
Winner = False
finished = False
vals = ['1','2', '3', '4', '5', '6', '7', '8', '9', '10']
suits = ['Yellows', 'Reds', 'Blacks']

deck = list(itertools.product(vals, suits))

random.shuffle(deck)

for val, suit in deck:
print('%s of %s' % (val, suit))



player1card = deck[0:len(deck)//2]
player2card = deck[len(deck)//2:]
print("this is player 1",player1card)
print("this is Player 2 ",player2card)
#winning list
P1_Win = []
P2_Win = []
#still need to work on the scoring
player1_score = 0
player2_score = 0

while len(deck) > 0:

if Winner == True:
player1card[0].append(P1_Win)
player2card[0].append(P1_win)
#definition of the rule and comparing the cards
if player1card[0][1] == "Blacks" and player2card[0][1] == "Blacks":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Reds" and player2card[0][1] == "Reds":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Yellows" and player2card[0][1] == "Yellows":
player1card[0][0] > player2card[0][0]
print("Player 1 wins")

if player1card[0][1] == "Blacks" and player2card[0][1] == "Yellow":
Winner == True
print("Player 1 wins")

if player1card[0][1] == "Reds" and player2card[0][1] == "Blacks":
Winner == True
print("Player 1 wins")

if player1card[0][1] == "Yellows" and player2card[0][1] == "Reds":
Winner == True
print("Player 1 wins")
else:
player1card.append(P2_Win)
player2card.append(P2_Win)
print("Player 2 wins")






python python-3.x






share|improve this question







New contributor




Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Tristan FarmerTristan Farmer

2




2




New contributor




Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Tristan Farmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by 200_success, AJNeufeld, Sᴀᴍ Onᴇᴌᴀ, Simon Forsberg 2 days ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, AJNeufeld, Sᴀᴍ Onᴇᴌᴀ, Simon Forsberg

If this question can be reworded to fit the rules in the help center, please edit the question.







put on hold as off-topic by 200_success, AJNeufeld, Sᴀᴍ Onᴇᴌᴀ, Simon Forsberg 2 days ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, AJNeufeld, Sᴀᴍ Onᴇᴌᴀ, Simon Forsberg

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    $begingroup$
    Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..." When you have fixed the code, please edit your post to include the working code and it can be reviewed."
    $endgroup$
    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago










  • $begingroup$
    For reviewers - cross post from SO
    $endgroup$
    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago














  • 1




    $begingroup$
    Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..." When you have fixed the code, please edit your post to include the working code and it can be reviewed."
    $endgroup$
    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago










  • $begingroup$
    For reviewers - cross post from SO
    $endgroup$
    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago








1




1




$begingroup$
Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..." When you have fixed the code, please edit your post to include the working code and it can be reviewed."
$endgroup$
– Sᴀᴍ Onᴇᴌᴀ
2 days ago




$begingroup$
Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..." When you have fixed the code, please edit your post to include the working code and it can be reviewed."
$endgroup$
– Sᴀᴍ Onᴇᴌᴀ
2 days ago












$begingroup$
For reviewers - cross post from SO
$endgroup$
– Sᴀᴍ Onᴇᴌᴀ
2 days ago




$begingroup$
For reviewers - cross post from SO
$endgroup$
– Sᴀᴍ Onᴇᴌᴀ
2 days ago










1 Answer
1






active

oldest

votes


















-2












$begingroup$

You say that you want the winner of a hand to receive both cards played, and you have a "winning" list per player (P1_Win and P2_Win), but you're never actually adding cards to either of these lists. You use the .append method of player1card and player2card, with the winning lists as arguments, but this usage of .append appends P1_Win or P2_Win to the playerXcard list (and remember the PX_Win lists are empty since you don't have any code adding cards to them).



You're looping while the deck size is non-zero, but you're never pulling cards off of the deck. Furthermore, I'm guessing you want the game to be played while the players are holding cards, and that their personal decks are diminishing with each hand. If this is correct, then you'd want to loop while the sum of the number of each players cards is non-zero, or while both of them are non-zero. For example,



while len(player1card) != 0 and len(player2card) != 0:


In accordance with the above two points, when a hand has been played, you need to remove the cards from each players list of cards, and add the cards to the winners list. It would probably result in cleaner code if you removed the cards for the current hand up front, compared them more directly, and then added them the appropriate winning list. Here's a possibility,



while len(player1card) != 0 and len(player2card) != 0:
# Pop the first card tuple off of each players deck.
player1hand = player1card.pop(0)
player2hand = player2card.pop(0)

# ...potentially skipping into some of the comparison logic.
# This compares the suits of each card first.
if player1hand[1] == "Blacks" and player2hand[1] == "Blacks":
# The values of the cards are compared second.
player1hand[0] > player2hand[0]
print("Player 1 wins")

# Assuming player 1 wins, your code might look like the following.
# You need to append each players card/hand to the winning list.
P1_win.append(player1hand)
P1_win.append(player2hand)


Also, you have a few cases where you've written Winner == True, which is comparing whether Winner is equal to True but I think you intended to set Winner equal to True (Winner = True).



There are some other things that could be discussed, but I think that should be enough to get you in the right direction.






share|improve this answer








New contributor




austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$




















    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    -2












    $begingroup$

    You say that you want the winner of a hand to receive both cards played, and you have a "winning" list per player (P1_Win and P2_Win), but you're never actually adding cards to either of these lists. You use the .append method of player1card and player2card, with the winning lists as arguments, but this usage of .append appends P1_Win or P2_Win to the playerXcard list (and remember the PX_Win lists are empty since you don't have any code adding cards to them).



    You're looping while the deck size is non-zero, but you're never pulling cards off of the deck. Furthermore, I'm guessing you want the game to be played while the players are holding cards, and that their personal decks are diminishing with each hand. If this is correct, then you'd want to loop while the sum of the number of each players cards is non-zero, or while both of them are non-zero. For example,



    while len(player1card) != 0 and len(player2card) != 0:


    In accordance with the above two points, when a hand has been played, you need to remove the cards from each players list of cards, and add the cards to the winners list. It would probably result in cleaner code if you removed the cards for the current hand up front, compared them more directly, and then added them the appropriate winning list. Here's a possibility,



    while len(player1card) != 0 and len(player2card) != 0:
    # Pop the first card tuple off of each players deck.
    player1hand = player1card.pop(0)
    player2hand = player2card.pop(0)

    # ...potentially skipping into some of the comparison logic.
    # This compares the suits of each card first.
    if player1hand[1] == "Blacks" and player2hand[1] == "Blacks":
    # The values of the cards are compared second.
    player1hand[0] > player2hand[0]
    print("Player 1 wins")

    # Assuming player 1 wins, your code might look like the following.
    # You need to append each players card/hand to the winning list.
    P1_win.append(player1hand)
    P1_win.append(player2hand)


    Also, you have a few cases where you've written Winner == True, which is comparing whether Winner is equal to True but I think you intended to set Winner equal to True (Winner = True).



    There are some other things that could be discussed, but I think that should be enough to get you in the right direction.






    share|improve this answer








    New contributor




    austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






    $endgroup$


















      -2












      $begingroup$

      You say that you want the winner of a hand to receive both cards played, and you have a "winning" list per player (P1_Win and P2_Win), but you're never actually adding cards to either of these lists. You use the .append method of player1card and player2card, with the winning lists as arguments, but this usage of .append appends P1_Win or P2_Win to the playerXcard list (and remember the PX_Win lists are empty since you don't have any code adding cards to them).



      You're looping while the deck size is non-zero, but you're never pulling cards off of the deck. Furthermore, I'm guessing you want the game to be played while the players are holding cards, and that their personal decks are diminishing with each hand. If this is correct, then you'd want to loop while the sum of the number of each players cards is non-zero, or while both of them are non-zero. For example,



      while len(player1card) != 0 and len(player2card) != 0:


      In accordance with the above two points, when a hand has been played, you need to remove the cards from each players list of cards, and add the cards to the winners list. It would probably result in cleaner code if you removed the cards for the current hand up front, compared them more directly, and then added them the appropriate winning list. Here's a possibility,



      while len(player1card) != 0 and len(player2card) != 0:
      # Pop the first card tuple off of each players deck.
      player1hand = player1card.pop(0)
      player2hand = player2card.pop(0)

      # ...potentially skipping into some of the comparison logic.
      # This compares the suits of each card first.
      if player1hand[1] == "Blacks" and player2hand[1] == "Blacks":
      # The values of the cards are compared second.
      player1hand[0] > player2hand[0]
      print("Player 1 wins")

      # Assuming player 1 wins, your code might look like the following.
      # You need to append each players card/hand to the winning list.
      P1_win.append(player1hand)
      P1_win.append(player2hand)


      Also, you have a few cases where you've written Winner == True, which is comparing whether Winner is equal to True but I think you intended to set Winner equal to True (Winner = True).



      There are some other things that could be discussed, but I think that should be enough to get you in the right direction.






      share|improve this answer








      New contributor




      austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      $endgroup$
















        -2












        -2








        -2





        $begingroup$

        You say that you want the winner of a hand to receive both cards played, and you have a "winning" list per player (P1_Win and P2_Win), but you're never actually adding cards to either of these lists. You use the .append method of player1card and player2card, with the winning lists as arguments, but this usage of .append appends P1_Win or P2_Win to the playerXcard list (and remember the PX_Win lists are empty since you don't have any code adding cards to them).



        You're looping while the deck size is non-zero, but you're never pulling cards off of the deck. Furthermore, I'm guessing you want the game to be played while the players are holding cards, and that their personal decks are diminishing with each hand. If this is correct, then you'd want to loop while the sum of the number of each players cards is non-zero, or while both of them are non-zero. For example,



        while len(player1card) != 0 and len(player2card) != 0:


        In accordance with the above two points, when a hand has been played, you need to remove the cards from each players list of cards, and add the cards to the winners list. It would probably result in cleaner code if you removed the cards for the current hand up front, compared them more directly, and then added them the appropriate winning list. Here's a possibility,



        while len(player1card) != 0 and len(player2card) != 0:
        # Pop the first card tuple off of each players deck.
        player1hand = player1card.pop(0)
        player2hand = player2card.pop(0)

        # ...potentially skipping into some of the comparison logic.
        # This compares the suits of each card first.
        if player1hand[1] == "Blacks" and player2hand[1] == "Blacks":
        # The values of the cards are compared second.
        player1hand[0] > player2hand[0]
        print("Player 1 wins")

        # Assuming player 1 wins, your code might look like the following.
        # You need to append each players card/hand to the winning list.
        P1_win.append(player1hand)
        P1_win.append(player2hand)


        Also, you have a few cases where you've written Winner == True, which is comparing whether Winner is equal to True but I think you intended to set Winner equal to True (Winner = True).



        There are some other things that could be discussed, but I think that should be enough to get you in the right direction.






        share|improve this answer








        New contributor




        austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        $endgroup$



        You say that you want the winner of a hand to receive both cards played, and you have a "winning" list per player (P1_Win and P2_Win), but you're never actually adding cards to either of these lists. You use the .append method of player1card and player2card, with the winning lists as arguments, but this usage of .append appends P1_Win or P2_Win to the playerXcard list (and remember the PX_Win lists are empty since you don't have any code adding cards to them).



        You're looping while the deck size is non-zero, but you're never pulling cards off of the deck. Furthermore, I'm guessing you want the game to be played while the players are holding cards, and that their personal decks are diminishing with each hand. If this is correct, then you'd want to loop while the sum of the number of each players cards is non-zero, or while both of them are non-zero. For example,



        while len(player1card) != 0 and len(player2card) != 0:


        In accordance with the above two points, when a hand has been played, you need to remove the cards from each players list of cards, and add the cards to the winners list. It would probably result in cleaner code if you removed the cards for the current hand up front, compared them more directly, and then added them the appropriate winning list. Here's a possibility,



        while len(player1card) != 0 and len(player2card) != 0:
        # Pop the first card tuple off of each players deck.
        player1hand = player1card.pop(0)
        player2hand = player2card.pop(0)

        # ...potentially skipping into some of the comparison logic.
        # This compares the suits of each card first.
        if player1hand[1] == "Blacks" and player2hand[1] == "Blacks":
        # The values of the cards are compared second.
        player1hand[0] > player2hand[0]
        print("Player 1 wins")

        # Assuming player 1 wins, your code might look like the following.
        # You need to append each players card/hand to the winning list.
        P1_win.append(player1hand)
        P1_win.append(player2hand)


        Also, you have a few cases where you've written Winner == True, which is comparing whether Winner is equal to True but I think you intended to set Winner equal to True (Winner = True).



        There are some other things that could be discussed, but I think that should be enough to get you in the right direction.







        share|improve this answer








        New contributor




        austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 2 days ago









        austin_yaustin_y

        1




        1




        New contributor




        austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        austin_y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.















            Popular posts from this blog

            Fairchild Swearingen Metro Inhaltsverzeichnis Geschichte | Innenausstattung | Nutzung | Zwischenfälle...

            Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...

            Marineschifffahrtleitung Inhaltsverzeichnis Geschichte | Heutige Organisation der NATO | Nationale und...