0

I am trying to check if two cards are of the same number(but not same suit).

For example here i would like the two kings to be approved as the same

9♥ 7♣ 8♦ Q♠ 10♣ 8♠ K♦ K♥

My problem is that i havent found a way to only match the number (or string) without the suit icon.

ruohola
  • 21,987
  • 6
  • 62
  • 97
Thymas
  • 49
  • 1
  • 6

1 Answers1

2

You could for example just compare the first characters:

>>> card1 = '9♥'
>>> card2 = '9♠'
>>> card1[0] == card2[0]
True
ruohola
  • 21,987
  • 6
  • 62
  • 97
  • 1
    Agreed. OP could split by the space character, iterate through each element in that list, and check the first character for matches. – Frontear May 02 '19 at 12:50