0

I am trying to create a display that shows the digits in a row using hashtags. The problem is, every time I output the results they all just get printed one below the other with only 1 row on the previous line (see below).

#
#
#
#
# ### 
  #  
###
#
###

How to get the output to look like this?

# ### ### # # ### ### ### ### ### ### 
#   #   # # # #   #     # # # # # # # 
# ### ### ### ### ###   # ### ### # # 
# #     #   #   # # #   # # #   # # # 
# ### ###   # ### ###   # ### ### ###

Here is the full code.

try:
    x = int(input("enter an integer value: "))
    x = str(x)
except ValueError:
    print("Sorry, this isn't an integer")

x = str(x)

a =  '''###
# #
# #
# #
###'''

b = '''#
#
#
#
#'''

c = '''### 
  #  
###
#
###'''

d = '''###
  #
###
  #
###'''

e = '''# #
# #
###
  #
  #'''

f = '''###
#
###
  #
###'''

g = '''###
#
###
# #
###'''

h = '''###
#
#
#
#'''

i = '''###
# #
###
# #
###'''

j = '''###
# #
###
  #
###'''

A = "0"
B = "1"
C = "2"
D = "3"
E = "4"
F = "5"
G = "6"
H = "7"
I = "8"
J = "9"

LEDs = {"0" : a, "1" : b,"2" : c, "3" : d, "4" : e, "5" : f, "6" : g, "7" : h, "8" : i, "9" : j}

Holy = []

for f in x:
    Holy.append(LEDs[f])

print(*Holy, end = "")

Thank you in advance for any help you give!

Jim432
  • 1
  • The way you wrote this it's just going to print each ASCII art one after the other vertically. What you'll need to do is for each ASCII block you want to print, split it into multiple lines, and then combine them one line at a time. – Iguananaut Jun 28 '21 at 09:27

1 Answers1

0

You can use zip() to convert your letters:

x = "246801357"

# changed this to conserve spaces - each letter is a 3x5 block
a = '###\n# #\n# #\n# #\n###'
b = ' # \n # \n # \n # \n # '
c = '###\n  #\n###\n#  \n###'
d = '###\n  #\n###\n  #\n###'
e = '# #\n# #\n###\n  #\n  #'
f = '###\n#  \n###\n  #\n###'
g = '###\n#  \n###\n# #\n###'
h = '###\n  #\n  #\n  #\n  #'
i = '###\n# #\n###\n# #\n###'
j = '###\n# #\n###\n  #\n###'

LEDs = {"0":a, "1":b, "2":c, "3":d, "4":e, "5":f, "6":g, "7":h, "8":i, "9":j}

Holy = [LEDs[f].split("\n") for f in x]

for line in zip(*Holy):
    for letter in line:
        print(f"{letter}", end=" ") # no line end but a space
    print() # terminate line
  

Output:

### # # ### ### ###  #  ### ### ###
  # # # #   # # # #  #    # #     #
### ### ### ### # #  #  ### ###   #
#     # # # # # # #  #    #   #   #
###   # ### ### ###  #  ### ###   #
Patrick Artner
  • 50,409
  • 9
  • 43
  • 69