I corrected the python code, I don’t know the python sythax so don’t copy paste it but you should understand the correction.
The error was that the loop counter is incremented at the start and each time a card is found or discarded.
def select(): #This selects 4 cards to use in the spinner
ncard = 0 #0 cards have been selected
loop = 0 #No cards have been pillars
card = [0, 0, 0, 0] #Generate an array for the 4 cards to be used
while ncard <= 3: #Do this 4 times
loop = loop + 1 #Add 1 to loop
index = random.randint(0, (len(cards)-1)) #Pick a random integer/card between 0 and the length of the card array (it holds the card code list)
if cards[index] not in pillarcodes or loop > 8: #If card is not a pillar or loop >8 then pick the card
card[ncard] = cards[index] #The nth card in the array is now the card code of the card selected
ncard = ncard + 1 #Add 1 to number of cards picked
return card #At the end, output the array of the 4 cards picked
def spin(): #This spins the wheel three times and returns the number of cards won
wins = 0 #0 cards have been won
for i in range(0, 3): #repeat 3 times
card = select() #Generate a card array of the cards picked in the select() function
card1 = card[random.randint(0, 3)] #Assign one of the 4 cards to the first card spun
card2 = card[random.randint(0, 3)] #Assign one of the 4 cards to the second card spun
card3 = card[random.randint(0, 3)] #Assign one of the 4 cards to the third card spun
if card1 == card2 and card2 == card3: #If all cards are equal
wins += 1 #Increase number of cards won by 1
return wins #Return the number of cards won (for use in a different function)