sorting - I am trying to generate 52 cards from a list and sort them in a specific order -


i trying output 52 cards in deck, , sort them in order (a-k, hearts, diamonds, clubs, spades). far have been able generate random choices, repeated cards, , sort alphabetical.

here code far:

import random  my_deck = []  def selsort(my_deck):     n = len(my_deck)     bottom in range(n-1):         mp = bottom         in range(bottom + 1, n):             if my_deck[i] < my_deck[mp]:                 mp =         my_deck[bottom], my_deck[mp] = my_deck[mp], my_deck[bottom]  while true:      = input("hit enter card: ")     cardnumber = random.choice( ('ace of ', '2 of ', '3 of ', '4 of ', '5 of ',      '6 of ', '7 of ', '8 of ', '9 of ', '10 of ', 'jack of ', 'queen of ',      'king of ') )     suit = random.choice( ('hearts', 'diamonds', 'clubs', 'spades') )     yourcard = cardnumber + suit     my_deck.append(yourcard)     print(yourcard)       in range(1):         if len(my_deck) >= 52:             print("now in order!")             selsort(my_deck)             print(my_deck) 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -