'Innacurate Higher/Lower [closed]

I used a code snippet that I found online of a higher/lower traditional card game, I wanted to use this for an enemy system. Half of the time it isn't very accurate though. Sometimes it says higher instead of lower and vice-versa. I tried to remake it in my own way, but it had the same issues. I'm not sure how else to fix it, any suggestions are appreciated. Correct, incorrect and draw are all similar things, that's why only correct is included in the snippet.

Edit: I've gotten my code to this point, but not sure how to connect the values to the ranks

ranks, values = [["Ace ","2","3","4","5","6","7","8","9","10","Jack ","Queen ","King "], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]]
suits = ['♠', '♦', '♥', '♣']
deck = []
        
for rank in ranks:
    for suit in suits:
        deck.append([rank + suit])
    
random.shuffle(deck)
enemy = deck.pop(0)
second = deck.pop(0)


Solution 1:[1]

You need a 2d array, one array that holds the strings for drawing to the screen, and one array paralelled to it with values 1-13 representing the actual value of the card for comparison. Then when you see a Rank[7] vs Rank[king] your value array will simple compare int[7] (which is the 8th value in the array) with int[12] (which is the 13th value in the array) and come back with a correct answer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Krausladen