python - Blackjack Game - displaying ASCII Graphics / Multiline Strings -


i'm pretty new python , trying create basic blackjack game using ascii graphics represent cards. i've placed card images in list of multiline strings , idea call specific index each 1 when card needs displayed.

however can't them print next each other, , no amount of tinkering seems work. here's code:

cards = ['''  ------- |k      | |       | |       | |       | |      k|  ------- ''', '''  ------- |q      | |       | |       | |       | |      q|  ------- ''', '''   ------- |j      | |       | |       | |       | |      j|  ------- ''', '''  ------- |10     | |       | |       | |       | |     10|  ------- ''', '''  ------- |9      | |       | |       | |       | |      9|  ------- ''', '''  ------- |8      | |       | |       | |       | |      8|  ------- ''', '''  ------- |7      | |       | |       | |       | |      7|  ------- ''', '''  ------- |6      | |       | |       | |       | |      6|  ------- ''', '''  ------- |5      | |       | |       | |       | |      5|  ------- ''', '''  ------- |6      | |       | |       | |       | |      6|  ------- ''', '''  ------- |5      | |       | |       | |       | |      5|  ------- ''', '''  ------- |4      | |       | |       | |       | |      4|  ------- ''', '''  ------- |3      | |       | |       | |       | |      3|  ------- ''', '''  ------- |2      | |       | |       | |       | |      2|  ------- ''', '''   ------- |a      | |       | |       | |       | |      a|  ------- ''' ]  blankcard = '''  ------- |xxxxxxx| |xxxxxxx| |xxxxxxx| |xxxxxxx| |xxxxxxx|  ------- '''   def displaycards():     print(cards[2] + cards[14], end='')  displaycards() 

the above code prints following:

 ------- |j      | |       | |       | |       | |      j|  -------   ------- |a      | |       | |       | |       | |      a|  -------  

i've tried using end='' rid of new line, no joy. have suggestions how can cards next each other?

thanks in advance!

interesting little problem. here's quick solution whipped up.

class card:

def topchar(char):     return '|{}      |'.format(char)  def botchar(char):     return '|      {}|'.format(char)  def print(char_list):     top = ' ------- '     side ='|       |'     topout = ''     topchar = ''     botchar = ''     blankside = ''     char in char_list:             topout += top + ' '             topchar += card.topchar(char) + ' '             blankside += side + ' '             botchar += card.botchar(char) + ' '     print(topout)     print(topchar)     print(blankside)     print(blankside)     print(blankside)     print(botchar)     print(topout) 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -