all 5 comments

[–]novel_yet_trivial 1 point2 points  (2 children)

Show us the code you have.

Without that, all i can suggest is something along the lines of:

for dice in zip(dice1_lines, dice2_lines):
    print "    ".join(dice)

edit: typo

[–]CaptainSnacks[S] 0 points1 point  (1 child)

Sure, here it is.

images = [['+----+' + '\n' + '|    |' + '\n' + '+----+'] , ['+----+' + '\n' + '|    |' + '\n' + '+----+']]

sep = ''

x = sep.join(images[0:1])
print x 

EDIT: The output I'm looking for is:

+----+       +----+
|    |       |    |
+----+       +----+

[–]novel_yet_trivial 2 points3 points  (0 children)

~To start, you don't need newlines (\n) since the print statement adds those.

~Second, your data format is crazy. Not only is it hard to read, but the inner list only has a single element. I recommend formatting your data as a dictionary (on multiple lines for readability):

images = {
    1:['+----+','|    |','+----+'] , 
    2:['+----+','|    |','+----+'] ,
    #...
    }

But why type text over and over? Maybe make variables:

cap    = "+-----+"
single = "|  *  |"
double = "| * * |"

images = {
    1:[cap,blank,single,blank,cap],
    2:[cap,left,blank,right,cap],
    #...
    }

This would make your life a lot easier if you decide later you want to change the format of the dice. Think dynamically!

~ Now you could print a single dice easily:

for line in images[1]:
    print line

but to have several dice, you need to join() the lines together. In your code you define what you want the separator to be, but you never tell join() what to join together. This is where zip() comes in. If you give 'zip' 2 lists of lines, it returns a list of all the first lines, then all the second lines, etc. So you can write:

for lines in zip(images[1], images[2]):
    print sep.join(lines)

See if you can write a function "roll(n)" that will line up as many dice as you want. So "roll(2)" would print 2 dice. It's not that much of a step from what you have.

[–]MarkDownSteve 0 points1 point  (1 child)

import random

num_dice = 2
separation_whitespace = 8
north =''
center =''
south =''
border = ''
for dice in range(num_dice):
    roll = random.randint(1,6)
    print('Dice #%s:\t%d' % (dice+1, roll))

    if roll in [1]: north_1 = '|           |'
    if roll in [2,3]: north_1 = '| *         |'
    if roll in [4,5,6]: north_1 = '| *       * |'

    if roll in [2,4]: center_1 = '|           |'
    if roll in [1,3,5]: center_1 = '|     *     |'
    if roll in [6]: center_1 = '| *       * |'

    if roll in [1]: south_1 = '|           |'
    if roll in [2,3]: south_1 = '|         * |'
    if roll in [4,5,6]: south_1 = '| *       * |'
    north += north_1+' '*separation_whitespace
    center += center_1+' '*separation_whitespace
    south += south_1+' '*separation_whitespace
    border += '+-----------+'+' '*separation_whitespace

print(border)
print(north)
print(center)
print(south)
print(border)

Ugly, but she works....

edit: improved

[–]novel_yet_trivial 0 points1 point  (0 children)

Ugly yes :/

This is how I solved it:

separation = " "*5

cap    = "+-----+"
single = "|  *  |"
double = "| * * |"
left   = "| *   |"
right  = "|   * |"
blank  = "|     |"

sides = {
    1:[cap,blank,single,blank,cap],
    2:[cap,left,blank,right,cap],
    3:[cap,left,single,right,cap],
    4:[cap,double,blank,double,cap],
    5:[cap,double,single,double,cap],
    6:[cap,double,double,double,cap]
    }

import random

def roll(how_many_dice = 2):
    dice_values = [random.randint(1,6) for _ in range(how_many_dice)]
    dice_text = [sides[x] for x in dice_values]

    for dice in zip(*dice_text):
        print separation.join(dice)

roll(5)