What's wrong with my code? Poker Hand challenge in Python, failing test cases 5 and 6 | Sololearn: Learn to code for FREE!
0

What's wrong with my code? Poker Hand challenge in Python, failing test cases 5 and 6

It seems that case 6 is supposed to be a Straight Flush, but my code isn't getting it right. No clue what case 5 is. https://code.sololearn.com/cWhLI382Tq1p/?ref=app

8th May 2023, 9:00 AM
Tim M
2 ответов
+ 1
Hard to be sure but it looks like your logic for straight (and for royal flush) assumes that hand[0] is the lowest value card, but the problem doesn't guarantee that for your input and you didn't sort the list.
8th May 2023, 3:00 PM
Orin Cook
Orin Cook - avatar
0
Woah, you're right! Adding the following line to sort the list by card value made it work: hand.sort(key=lambda x: values.index(x[0:-1])) Thanks!
8th May 2023, 3:22 PM
Tim M