rric

Mu_03_Cards

Oct 25th, 2021
439
146 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Create a deck of cards with two nested for loops
  2. # Copyright 2021 Roland Richter
  3.  
  4. suits = ['♠', '♣', '♥', '♦']
  5. ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10',
  6.          'J', 'Q', 'K', 'A']
  7.  
  8. # Create a standard 52-card deck:
  9. # start with an empty deck
  10. cards = []
  11.  
  12. # for each suit, and each rank, add the corresponding card
  13. for suit in suits:
  14.     print("---", suit, "---")
  15.     for rank in ranks:
  16.         print("-", rank, "-")
  17.         cards.append(suit + "-" + rank)
  18.  
  19. print(len(cards), "cards:")
  20. print(cards)
  21.  
  22. # ----------------------------------------------------------------------
  23. # This program is free software: you can redistribute it and/or modify
  24. # it under the terms of the GNU General Public License as published by
  25. # the Free Software Foundation, either version 3 of the License, or
  26. # (at your option) any later version.
  27. #
  28. # This program is distributed in the hope that it will be useful,
  29. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  30. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  31. # GNU General Public License for more details.
  32. #
  33. # You should have received a copy of the GNU General Public License
  34. # along with this program.  If not, see <https://www.gnu.org/licenses/>.
  35.  
RAW Paste Data