'Print magnified ASCII alphabet patterns side-by-side

I have created a function which will give me a magnified alphabet pattern of letter K. I have created another function which will print the pattern. I want to print two pattern K side-by-side but when I execute the code it prints 2nd pattern below the 1st pattern

How do I solve this?

def letter_k(pattern):
    k = ''
    for row in range(7):
        for col in range(6):
            if((col == 0) or ((row == 0 or row == 6) and (col == 5)) 
                           or ((row == 1 or row == 5) and (col == 4)) 
                           or ((row == 2 or row == 4) and (col == 3)) 
                           or ((row == 3) and (col == 2))):
                k = k + pattern
            else:
                k = k + ' '
        k = k + '\n'
    return k

def name():
    print(letter_k('*'),letter_k('+'))

name()


Solution 1:[1]

You can split the output of the two calls to letter_k, zip them, and then rejoin them:

def name():
    print('\n'.join(' '.join(l) for l in zip(letter_k('*').split('\n'), letter_k('+').split('\n'))))

With this change, your code would output:

*    * +    +
*   *  +   + 
*  *   +  +  
* *    + +   
*  *   +  +  
*   *  +   + 
*    * +    +

Solution 2:[2]

To print the letters side by side you have to concatenate the individual lines. That generally means splitting the lines, joining the corresponding lines, then putting the combined lines back together. It helps that your letters are in a rectangular block, so you don't have to work out the padding for each line.

k1 = letter_k('*')
k2 = letter_k('+')
lines = [' '.join(rows) for rows in zip(k1.splitlines(), k2.splitlines())]
ks = '\n'.join(lines)
print(ks)

Here is an IDEOne link to play with: https://ideone.com/OQStFd

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 blhsing
Solution 2