def make_sorted_deck():
''' Return a sorted deck of cards. Each card is
represented by a string as follows:
"queen of hearts". The cards are ordered by rank and then suit within rank.
:return: The sorted deck of cards, as a list of strings
EXAMPLE: make_sorted_deck() == ['2 of spades', '2 of hearts', '2 of clubs', ..., 'ace of clubs', 'ace of diamonds'] '''
#Hint: Use the previous functions and two nested for loops.
sorted_deck = []
for i in get_ranks():
for j in get_suits():
sorted_deck.append("{0} of {1}".format(i,j))
return sorted_deck
print(make_sorted_deck())
def shuffle(deck):
''' Randomly shuffle the cards in deck into a newly created deck of cards (list).
:param: deck: A deck of cards
:return: A new list, consisting of a random shuffle of deck.
EXAMPLE: shuffle(['2 of hearts', '3 of diamonds', 'jack of spades', '2 of clubs']) could return ['jack of spades', '3 of diamonds', '2 of hearts', '2 of clubs']
#REQUIREMENTS: Please implement the following algorithm: Use a while loop to repeatedly pick a random card from deck, remove it, and add it to a newly created list. '''
How would I shuffle the list created by make_sorted_deck()
?
I know there is a a function that I can import to shuffle the deck, but the way I am required to do it is to take out 1 random card and append it to a new list to have a shuffled list.