nord vpnnord vpn
Ad

Untitled

mail@pastecode.io avatar
unknown
python
a year ago
1.4 kB
1
Indexable
Never
import random

def create_deck():
  """ Takes no parameter
  Creates and returns a 2D-list """
  
  # an intially empty deck
  deck = []
  suits = ["RED", "BLK"]
  values = []
  
  # creates a list of all face values
  for x in range(2,10):
    values.append(x)
  
  # creates cards [s,f] and inserting them to the deck
  for s in suits:
    for f in values:
      deck.append([s, f])
  return deck

def shuffle(deck):
    """Takes a 2-D list
        Returns a shuffled 2-D list"""
    
    # copies the deck to a new list, so the original deck remains same    
    shdeck = deck[:]
    random.shuffle(shdeck)
    return shdeck


def deal(deck):
  board = []
  for row in range(3):
    board.append([])
    for col in range(3):
      board[row].append(deck.pop(0))

  return board

def show_board(board):
  for line in board:
    print(line)
  return board


    
# main() function should call all other functions in the appropriate order to run the game
def main():
    #create and print the deck of cards
    deck = create_deck()
    # print(f"\nDeck: {deck}")
    #create and print the shuffled deck of cards
    shdeck = shuffle(deck)
    print(f"\nShuffled deck: {shdeck}")

    testOutput_0 = deal(shdeck)
    print(f"\n{testOutput_0}")

    testOutput_1 = show_board(deck)
    print(f"{testOutput_1}, end = """)
    
    # call other functions here
      
# main guard    
if __name__ == "__main__":
    main()
    

nord vpnnord vpn
Ad