python 3.x - display text for a value in a list python3 -


well i've got 2 lists:

deck=[2,2,2,2,3,3,3,3,4,4,4,4,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11]  symbols=['\u2660', '\u2661', '\u2662', '\u2663','\u2660', '\u2661', '\u2662', '\u2663','\u2660',          '\u2661', '\u2662', '\u2663','\u2660', '\u2661', '\u2662', '\u2663','\u2660', '\u2661', '\u2662', '\u2663','\u2660', '\u2661', '\u2662', '\u2663','\u2660', '\u2661', '\u2662', '\u2663','\u2660', '\u2661', '\u2662', '\u2663'] 

and function

def dealcard(deck,participant):#deal cards , chooses between player , house string z   participant.append(deck.pop())   if z==1:       print('\nyou got  %s ' %("{} {}".format(player[len(player)-1],symbols.pop())))    else:       print('\nhouse got %s ' %("{} {}".format(house[len(house)-1],symbols.pop())))` 

is there way display letter 'a' (stands ace) instead of 11?

eg.

>>>you got ♡  

instead of

>>>you got 11 ♡  

use numbers 1..13 represent card ranks (a,2,3,...,q,k). use numbers 0..3 represent suits. either make card object both of these values or mathematically compose them int (i 4 * rank + suit). using object this:

def card(object):     def __init__(self, rank, suit):         self.rank = rank         self.suit = suit      def __str__(self):         return ["a","2","3","4","5","6","7","8","9","10","j","q","k"][self.rank-1] +           ['\u2660', '\u2661', '\u2662', '\u2663'][suit] 

with str function, you'll able use print , such. build deck list of card objects:

deck = [] rank in range(13):     suit in range(4):         deck.append(card(rank+1, suit)) random.shuffle(deck) 

hands likewise list of cards. totaling hand this:

def total(hand):     acefound, soft = false, false     total = o      c in hand:         if c.rank > 10:             total += 10         else:             total += c.rank         if c.rank == 1:             acefound = true      if acefound , total < 12:         total += 10         soft = true      return total, soft 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -