0

I need assistance. I am trying to program a game of Dice poker on python. I have two-thirds completed all of the programmings but have come across a slight hiccup. I have used both Integers and Lists to compute what numbers were rolled and how many times they appeared for both the player and dealer(computer). I have then coded up to determine whether who won, loss or if it was a draw, but it seems that it won't work because I have used both Integers and Lists. Is there a way to use both Integers and Lists or would I have to use only one?

die_count = [0,0,0,0,0,0,0]
    die_index = 0
    while die_index < len(player_hand):
        die_count[die_value] += 1
        die_index += 1
    print(die_count)

This is what I have coded to calculate how many times a specific number in its index has appeared, from rolling 5 dice

if 5 in die_count and die_count1 < 5 in die_count:
        print("** Player Wins! **")
        print("** Dealer Loses! **")
elif 4 in die_count and 1 in die_count and die_count1 < 4 in die_count and 1 in die_count:
        print("** Player Wins! **")
        print("** Dealer Loses! **")
elif 3 in die_count and 2 in die_count and die_count1 < 3 in die_count and 2 in die_count:`
        print("** Player Wins! **")
        print("** Dealer Loses! **")
elif 3 in die_count and die_count1 < 3 in die_count:
        print("** Player Wins! **")
        print("** Dealer Loses! **")
elif 4 in die_count and die_count1 < 4 in die_count:
        print("** Player Wins! **")
        print("** Dealer Loses! **")
elif 2 > die_count and die_count1 < 2:
        print("** Player Wins! **")
        print("** Dealer Loses! **")
elif 5 in die_count1 and die_count < 5 in die_count1:
        print("** Player Loses! **")
        print("** Dealer Wins! **")
elif 4 in die_count1 and 1 in die_count1 and die_count < 4 in die_count1 and 1 in die_count1:
        print("** Player Loses! **")
        print("** Dealer Wins! **")
elif 3 in die_count1 and 2 in die_count1 and die_count < 3 in die_count1 and 2 in die_count1:
        print("** Player Loses! **")
        print("** Dealer Wins! **")
elif 3 in die_count1 and die_count < 3 in die_count1:
        print("** Player Loses! **")
        print("** Dealer Wins! **")
elif 4 in die_count1 and die_count < 4 in die_count1:
        print("** Player Loses! **")
        print("** Dealer Wins! **")
elif 2 in die_count1 and die_count < 2 in die_count1:
        print("** Player Loses! **")
        print("** Dealer Wins! **")
elif 5 in die_count and 5 in die_count1:
        print("** Draw! **")
elif 4 in die_count and 1 in die_count and 4 in die_count1 and 1 in die_count1:
        print("** Draw! **")
elif 3 in die_count and 2 in die_count and 3 in die_count1 and 2 in die_count1:
        print("** Draw! **")
elif 3 in die_count and 3 in die_count1:
        print("** Draw! **")
elif 4 in die_count and 4 in die_count1:
        print("** Draw! **")
elif 2 in die_count and 2 in die_count1:
        print("** Draw! **")

This is what I have coded to determine whether who won, loss, etc.

When I try to run the program it comes up by saying that either '>' or '<' is not supported between instances of 'int' and 'list'. What I am trying to say by wording the huge bit of code, is that if the either player's/dealer's hand is less than the other's hand, then it prints the obligated response.

Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50
Raffaele Lioi
  • 11
  • 1
  • 2

1 Answers1

0

In your code, die_count is a list ( die_count = [0,0,0,0,0,0,0]`).

A few line later, I see 2 > die_count. So you're comparing 2 with the list.

You're asking the question: "Is two greater than [0,0,0,0,0,0,0]". As an human I don't have an answer to this question, Python neither.

It's allowd to use integers and lists in the same program, but you can't compare an integer to a list because it does not make sense. What are you trying to express at the line elif 2 > die_count and die_count1 < 2:?

As I don't know what is die_count1, I don't think I can help more.

Julien Palard
  • 8,736
  • 2
  • 37
  • 44
  • What I'm trying to say is that if in die_count's List, the ranked hand for 2 = a pair, is greater than the die_count1's List, which is the computer as the dealer, and die_count1's ranked hand is less than the ranked hand of the Player, then it should print out the winner and loser. – Raffaele Lioi Sep 05 '19 at 03:51