I am coding a teminal based poker “simulator” and I am trying to check if any of the users has a flush or not.
I have a if/else where I test the best hand first and the worst hand last so it passes down if return is false.
this is the flush function.
[‘5s’, ‘8s’, ‘9s’, ‘As’, ‘2s’] gives true
[‘5s’, ‘2h’, ‘8s’, ‘9s’, ‘As’, ‘2s’] gives false
def is_flush(h): suits = [x[-1] for x in h] if len(set(suits)) == 1: return True, h else: return False
The function is correct isnt it? I dont understand why it doesnt work when a card with another suit is added to the hand? It doesnt make sense