I am trying to create a program that gives you 3 random "common cards" from a list to be your starter cards. Whenever I try to run it, I am given the first one fine, but then it says [None]. Is there a way to put my functions (cards) into this list, and have the program return 3 random cards?
- I tried using random.sample(common_cards, 3)0, expecting it to give me 3 of the functions.
when I ran it, I would get(for example), jerry [None]
My code is:
import random
#this is the player deck. It *hopefully* will randomly gain 3 common cards upon running
player_deck = []
#these are cards
def orc():
print("orc")
def spirit():
print("spirit")
def bob():
print("bob")
def jerry():
print("jerry")
#the cards above are "common" cards, and will be drawn as such
common_cards = [orc, spirit, bob, jerry]
#this parts goal is to draw three of the functions as cards- No duplicates.
cards = random.sample(common_cards, 3)[0]()
#this adds the cards to be displayed in the player deck
player_deck.append(cards)
print(player_deck)