[Tutor] Printing multi-line variables horizontally

Greg Markham greg.markham at gmail.com
Fri Aug 8 10:50:53 CEST 2014


Hello,

Python novice back again.  :)  I'm making progress in my learning process,
but struggling whenever attempting to creatively go beyond what's required
in the various chapter assignments.  For example, there's a simple random
die roller program that looks like the following:


# Craps Roller
# Demonstrates random number generation

import random

# generate random numbers 1 - 6
die1 = random.randint(1, 6)
die2 = random.randrange(6) + 1

total = die1 + die2

print("You rolled a", die1, "and a", die2, "for a total of", total)

input("\n\nPress the enter key to exit.")


I wanted to make it a little more interesting by using ascii art
representations of the six die.  When printing, however, they do so
vertically and not horizontally.  Here's a snippet of the code:


die_1 = """
.-----.
|     |
|  o  |
|     |
`-----'"""

die_2 = """
.-----.
|o    |
|     |
|    o|
`-----'"""

print(die_1, die_2)


So, how would I get this to display horizontally?

Like so...
.-----.   .-----.
|     |   |o    |
|  o  |   |     |
|     |   |    o|
`-----'   `-----'

Thanks,

Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140808/0272b8e6/attachment.html>


More information about the Tutor mailing list