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>My approach would be to first order the cards by size (4,7,9,12,13) and then write functions like checkPairs(), checkFlush() and apply them to it.</p>

<p>Ordering the cars will help you because you will be able to check for example if you have two cards of the same value.. they will be consecitve</p>

<pre><code>function checkPairs(){
   card = hand[0];
   pairs=1;
   for (i =1; i&lt;5; i++){
      if(card == hand[1]){
      pairs++;
   }else{
      pairs=1;
   }
   return pairs;
}
</code></pre>

<p>or for a flush</p>

<pre><code>card = hand[0];
return_value ="flush";

if(card = 10)
   return_value ="royal_flush";

for (i =1; i&lt;5; i++){
      if((hand[1] - card) !=1){
      return false;
   }
return return_value;
</code></pre>

python combinations