Blackjack Game - displaying ASCII Graphics / Multiline Strings
<p>I'm pretty new to Python and currently trying to create a basic blackjack game using ASCII graphics to represent the cards. I've placed the card images in a list of multiline strings and the idea is to call the specific index for each one when a card needs to be displayed. </p>

<p>However I can't get them to print next to each other, and no amount of tinkering seems to get it to work. Here's the code: </p>

<pre><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()
</code></pre>

<p>The above code prints the following:</p>

<pre><code> -------
|J      |
|       |
|       |
|       |
|      J|
 ------- 
 -------
|A      |
|       |
|       |
|       |
|      A|
 ------- 
</code></pre>

<p>I've tried using end='' to get rid of the new line, but no joy. Does anyone have any suggestions about how I can get the cards next to each other?</p>

<p>Thanks in advance!</p>

<p>Interesting little problem.  Here's a quick solution that I whipped up.</p>

<p><code>class Card:</code></p>

<pre><code>def topchar(char):
    return '|{}      |'.format(char)

def botchar(char):
    return '|      {}|'.format(char)

def print(char_list):
    top = ' ------- '
    side ='|       |'
    topout = ''
    topchar = ''
    botchar = ''
    blankside = ''
    for 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)
</code></pre>

python python-3.x