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>With the way you're doing it, that would be very difficult. When you write</p>

<pre><code>end=''
</code></pre>

<p>That only gets rid of the newline at the very end of the printed text. The problem is, every one of your cards has a new line on the right side:</p>

<pre><code> -------
|J      |
|       |
|       | # &lt;--- Newline here
|       |
|      J|
 ------- 
</code></pre>

<p>You would need to create a function that takes a list of cards, and creates one long line of them. That will be a solid project in its own. You would have to take the strings that make up the cards, cut them into lines (cut on each new line), place all the corresponding lines together, getting rid of the newlines in between, then glue all the pieces together. I might actually try this for a morning project now. </p>

<p>And instead of hard coding all the cards like you have, create a function that you give a card value to, and it creates a card for you.</p>

python python-3.x