Compare multiple values in a poker game in python
<p>Here's the question:
For a poker game, I want to be able to compare multiple variables efficiently. 
This is the body of the code, one has to enter five cards starting from the one with the highest value (ace = 1, king = 13):</p>

<pre><code>print("*********")
print("P O K E R")
print("*********")
print("Type in your cards starting from the highest value: ")
print()
#values going from 1 (ace) to 13 (king) and suits: 1 (spades), 2 (hearts), 3 (diamonds) and 4 (clubs)
value1 = int(input("1. Value: "))
suit1 = int(input("1. Suit: "))
value2 = int(input("2. Value: "))
suit2 = int(input("2. Suit: "))
value3 = int(input("3. Value: "))
suit3 = int(input("3. Suit: "))
value4 = int(input("4. Value: "))
suit4 = int(input("4. Suit: "))
value5 = int(input("5. Value: "))
suit5 = int(input("5. Suit: "))
</code></pre>

<p>I am using <code>if</code> statements to evaluate poker hands and determine their <a href="http://www.cardplayer.com/rules-of-poker/hand-rankings" rel="nofollow">ranking</a>. For me it seems the easiest way. An example of an evaluation would be:</p>

<pre><code>#Evaluating the hand and comparing the cards
c = [value1, value2, value3, value4, value5]

#four of a kind
if c[0] == c[1] == c[2] == c[3] != c[4] or c[0] == c[1] == c[2] == c[4] != c[3] or c[0] == c[1] == c[3] == c[4] != c[2] or c[0] == c[2] == c[3] == c[4] != c[1]  or c[1] == c[2] == c[3] == c[4] != c[0]:
    print("You have Four Of A Kind!")
#three of a kind
#two pairs
#one pair
#highest card
</code></pre>

<p>This code checks if 1 of 5 combinations is true. It is inefficient and time-consuming. And as I want to code further the options of "three of a kind", "two pairs" and "one pair", the combinations get bigger. Is there a way to shorten the <code>if</code> statement?</p>

<p>Rather than creating tons of <code>if/elif</code> branches, you might want to consider building the complete list of all poker combinations, and use that to compare drawn hands to this pre-built list.  The number of 5-card poker hand combinations is ~2.6 million. This includes 1.3 million high card combinations which you could exclude from your pre-built list and use a "fall back" check when nothing else matches.</p>

<p>Check out this website <a href="http://people.math.sfu.ca/~alspach/comp18/" rel="nofollow">http://people.math.sfu.ca/~alspach/comp18/</a></p>

python combinations