At first I have three cards like this:
___ ___ ___
| | | | | |
| A | | A | | Q |
|___| |___| |___|
and then I shuffle them to this:
___ ___ ___
| | | | | |
| 1 | | 2 | | 3 |
|___| |___| |___|
So now I want to write a function that generates a random number between 1 and 3 and assign it to be the value of the Q card. For example if I generate number 2, the cards when turned around will have this order:
___ ___ ___
| | | | | |
| A | | Q | | A |
|___| |___| |___|
So I came up with a code like this
def CreateCard(card):
print (' _____')
print ('| |')
print ('| ',card,' |',sep='')
print ('|_____|')
def shuffle():
Q = random.randint(1,4)
if Q == 1:
cards = ['Q','A','A']
elif Q == 2:
cards = ['A','Q','A']
else:
cards = ['A','A','Q']
return cards
for card in shuffle():
CreateCard(card)
I guess what I'm asking is this the optimal way since I don't think I'm allowed to use any other function of random module besides randint or randrange.