def run_counter(card_list, num_cards):
hand = functions1.hand_sample(card_list, num_cards)
hand1 = functions1.hand_shuffle(card_list, num_cards)
srt_hand = sorted(hand)
srt_hand1 = sorted(hand1)
prop_hand = functions1.proper_hand(srt_hand)
prop_hand1 = functions1.proper_hand(srt_hand1)
run1 = 0
i = 0
for count in range(len(srt_hand)-1):
if srt_hand[i] == srt_hand[i+1] - 1:
run1 += 1
run2 = 0
i = 0
for count in range(len(srt_hand1)-1):
if srt_hand1[i] == srt_hand1[i+1] - 1:
run2 += 1
return run1+1, run2+1, prop_hand, prop_hand1
I have a hand of cards that I generate, and store in a sorted list 'srt_hand' and 'srt_hand1'. I made a function that should count the length of the runs in the hand. I go to test it but it keeps saying that 'if srt_hand[i] == srt_hand[i+1] - 1:' is an unsupported operand type. Why is that? It doesn't make any sense since I'm indexing a list of integers...
I had this before, with the same sorting technique and it worked (except it stopped after the first run):
run1 = 0
i = 0
while i < len(srt_hand)-1 and run1 < 2:
while i < len(srt_hand)-1 and srt_hand[i] == srt_hand[i+1] - 1:
if srt_hand[i] == srt_hand[i+1]:
i += 1
run1 += 1
i += 1
i += 1
run2 = 0
i = 0
while i < len(srt_hand1)-1 and run2 < 2:
while i < len(srt_hand1)-1 and srt_hand1[i] == srt_hand1[i+1] - 1:
if srt_hand[i] == srt_hand[i+1]:
i += 1
run2 += 1
i += 1
i += 1
return run1+1, run2+1, prop_hand, prop_hand1