mardi 25 octobre 2016

Printing random cards (Python)

I am writing a program to deal a deck of cards. I need them to be dealt at random. I'm just not sure to print them randomly. This is the code I have so far..

import random


def create_deck():
    for i in range(10):
        pip = random.choice(PIPS)
        suit = random.choice(SUITS)
        card = (pip, suit)


def deal_deck(DECK):
    for pip in PIPS:
        for suit in SUITS:
            print(pip + suit,end=" ")
        print()

CLUB = "\u2663"
HEART = "\u2665"
DIAMOND = "\u2666"
SPADE = "\u2660"

PIPS = ("A","2","3","4","5","6","7","8","9","10","J","Q","K")
SUITS = (CLUB, SPADE, DIAMOND, HEART)
DECK= []

create_deck
deal_deck(DECK)




Aucun commentaire:

Enregistrer un commentaire