the ones used in blackjack and other games (to keep things simplei just let the ace be )in [ ]deck[: out[ ]ah jh kh qh nowbased on what said abovedrawing hand of cards from the desk could be written asin [ ]def draw(deckn= )return deck take(np random permutation(len(deck))[: ]in [ ]draw(deckout[ ]ad kc suppose you wanted two random cards from each suit because the suit is the last character of each card namewe can group based on this and use applyin [ ]get_suit lambda cardcard[- last letter is suit in [ ]deck groupby(get_suitapply(drawn= out[ ] kd kh alternatively in [ ]deck groupby(get_suitgroup_keys=falseapply(drawn= out[ ]kc jc ad data aggregation and group operations www it-ebooks info