-1

When a user enters a word, my Python program enlarges it with asterisks.But, when the user enters a word, it prints vertically instead of horizontally.

My question is - How to pring the enlarged letter horizantally (SIDE BY SIDE) instead of vertically?

Here is my code -

def a():
    row1 = [3]
    row2 = [2, 4]
    row3 = [1, 2, 3, 4, 5]
    row4 = [1, 5]
    row5 = [1, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def b():
    row1 = [1, 2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 2, 3, 4]
    row4 = [1, 5]
    row5 = [1, 2, 3, 4]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def c():
    row1 = [2, 3, 4, 5]
    row2 = [1]
    row3 = [1]
    row4 = [1]
    row5 = [2, 3, 4, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def d():
    row1 = [1, 2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 5]
    row4 = [1, 5]
    row5 = [1, 2, 3, 4]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def e():
    row1 = [1, 2, 3, 4, 5]
    row2 = [1]
    row3 = [1, 2, 3, 4, 5]
    row4 = [1]
    row5 = [1, 2, 3, 4, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def f():
    row1 = [1, 2, 3, 4, 5]
    row2 = [1]
    row3 = [1, 2, 3, 4, 5]
    row4 = [1]
    row5 = [1]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def g():
    row1 = [2, 3, 4, 5]
    row2 = [1]
    row3 = [1, 3, 4, 5]
    row4 = [1, 5]
    row5 = [2, 3, 4, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def h():
    row1 = [1, 5]
    row2 = [1, 5]
    row3 = [1, 2, 3, 4, 5]
    row4 = [1, 5]
    row5 = [1, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def i():
    row1 = [1, 2, 3, 4, 5]
    row2 = [3]
    row3 = [3]
    row4 = [3]
    row5 = [1, 2, 3, 4, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def j():
    row1 = [1, 2, 3, 4, 5]
    row2 = [3]
    row3 = [3]
    row4 = [1, 3]
    row5 = [2, 3]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def k():
    row1 = [1, 4]
    row2 = [1, 3]
    row3 = [1, 2]
    row4 = [1, 3]
    row5 = [1, 4]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def l():
    row1 = [1]
    row2 = [1]
    row3 = [1]
    row4 = [1]
    row5 = [1, 2, 3]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def m():
    row1 = [1, 5]
    row2 = [1, 2, 4, 5]
    row3 = [1, 3, 5]
    row4 = [1, 5]
    row5 = [1, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def n():
    row1 = [1, 5]
    row2 = [1, 2, 5]
    row3 = [1, 3, 5]
    row4 = [1, 4, 5]
    row5 = [1, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def o():
    row1 = [2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 5]
    row4 = [1, 5]
    row5 = [2, 3, 4]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def p():
    row1 = [1, 2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 2, 3, 4]
    row4 = [1]
    row5 = [1]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def q():
    row1 = [3]
    row2 = [2, 4]
    row3 = [1, 3, 5]
    row4 = [2, 4]
    row5 = [3, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def r():
    row1 = [1, 2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 2, 3, 4]
    row4 = [1, 3]
    row5 = [1, 4, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def s():
    row1 = [2, 3, 4, 5]
    row2 = [1]
    row3 = [2, 3, 4]
    row4 = [5]
    row5 = [1, 2, 3, 4]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def t():
    row1 = [1, 2, 3, 4, 5]
    row2 = [3]
    row3 = [3]
    row4 = [3]
    row5 = [3]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def u():
    row1 = [1, 5]
    row2 = [1, 5]
    row3 = [1, 5]
    row4 = [1, 5]
    row5 = [2, 3, 4]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def v():
    row1 = [1, 5]
    row2 = [1, 5]
    row3 = [1, 5]
    row4 = [2, 4]
    row5 = [3]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def w():
    row1 = [1, 5]
    row2 = [1, 5]
    row3 = [1, 3, 5]
    row4 = [1, 2, 4, 5]
    row5 = [1, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def x():
    row1 = [1, 5]
    row2 = [2, 4]
    row3 = [3]
    row4 = [2, 4]
    row5 = [1, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def y():
    row1 = [1, 5]
    row2 = [2, 4]
    row3 = [3]
    row4 = [3]
    row5 = [3]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")


def z():
    row1 = [1, 2, 3, 4, 5]
    row2 = [4]
    row3 = [3]
    row4 = [2]
    row5 = [1, 2, 3, 4, 5]
    coordinates = [row1, row2, row3, row4, row5]
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                print("*", end="")
            else:
                print(" ", end="")
        print("")



word = input('Enter a word - ').lower().strip()

while True:
    if not word.isalpha():
        print("Sorry, but you need to enter a valid word containing only letters!")
        print(" ")
        word = input("Enter a word - ").lower().strip()
    else:
        break

for letter in word:
    if letter == "a":
        a()
    elif letter == "b":
        b()
    elif letter == "c":
        c()
    elif letter == "d":
        d()
    elif letter == "e":
        e()
    elif letter == "f":
        f()
    elif letter == "g":
        g()
    elif letter == "h":
        h()
    elif letter == "i":
        i()
    elif letter == "j":
        j()
    elif letter == "k":
        k()
    elif letter == "l":
        l()
    elif letter == "m":
        m()
    elif letter == "n":
        n()
    elif letter == "o":
        o()
    elif letter == "p":
        p()
    elif letter == "q":
        q()
    elif letter == "r":
        r()
    elif letter == "s":
        s()
    elif letter == "t":
        t()
    elif letter == "u":
        u()
    elif letter == "v":
        v()
    elif letter == "w":
        w()
    elif letter == "x":
        x()
    elif letter == "y":
        y()
    elif letter == "z":
        z()

This program prints the word vertically.

here is an example of how it prints - C:\Users\yaswa\PycharmProjects\pythonProject\venv\Scripts\python.exe "C:\py letters\blah.py"

Enter a word - hi
*   *
*   *
*****
*   *
*   *
*****
  *  
  *  
  *  
*****

Process finished with exit code 0

What I expect - I expect it to print "HI" side by side. Like this -

*   * *****
*   *   *
*****   *
*   *   *
*   * *****
Zero
  • 1,807
  • 1
  • 6
  • 17
  • 2
    Pls provide a minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example. People are unlikely to read a lot of code. – Dinux Jul 04 '23 at 16:25
  • Each letter is printed to a new line, you don't have any code to put them side by side. – Peter Jul 04 '23 at 16:29
  • What you are _expecting_ is one thing, what you have _implemented_ is another thing. Look at what each function (`a()` to `z()`) does and you will see that you set your "coordinates" and print them instantly (within each function). So how should the cursor (the thing which indicates where a letter is printed) go back then? – Markus Safar Jul 04 '23 at 16:30
  • You're printing alphabet by alphabet, that too on multiple lines, it may not be possible to go back to the previous lines. You can try using a temporary file to store the intermediate output and appending characters to it. – Zero Jul 04 '23 at 16:32
  • Your question is at the design level (“I designed it incorrectly so that words are vertical not horizontal”). What specific technical question do you have? – bob Jul 04 '23 at 16:37
  • Can you guys tell me an another way to do this? – Yash Kandra Jul 04 '23 at 16:40
  • You simply have to design your thing to print each letter by row. For instance, using "hi" as an example, you print the first row of H and I together, then the next row of H and I together, on and on til there are no more rows. Your functional way of creating letters is very cumbersome and should be entirely reconsidered. Technically, this would likely be much better if you treated stdout like a buffer and didn't use print, at all. – OneMadGypsy Jul 04 '23 at 16:51

3 Answers3

0

Your code was too redundant, so I rewrote it.

alphabets = {
    "a" : [
        [3],
        [2, 4],
        [1, 2, 3, 4, 5],
        [1, 5],
        [1, 5]
    ],
    "b" : [
        [1, 2, 3, 4],
        [1, 5],
        [1, 2, 3, 4],
        [1, 5],
        [1, 2, 3, 4]
    ],
    "c" : [
        [2, 3, 4, 5],
        [1],
        [1],
        [1],
        [2, 3, 4, 5]
    ],
    "d" : [
        [1, 2, 3, 4],
        [1, 5],
        [1, 5],
        [1, 5],
        [1, 2, 3, 4]
    ],
    "e" : [
        [1, 2, 3, 4, 5],
        [1],
        [1, 2, 3, 4, 5],
        [1],
        [1, 2, 3, 4, 5]
    ],
    "f" : [
        [1, 2, 3, 4, 5],
        [1],
        [1, 2, 3, 4, 5],
        [1],
        [1]
    ],
    "g" : [
        [2, 3, 4, 5],
        [1],
        [1, 3, 4, 5],
        [1, 5],
        [2, 3, 4, 5]
    ],
    "h" : [
        [1, 5],
        [1, 5],
        [1, 2, 3, 4, 5],
        [1, 5],
        [1, 5]
    ],
    "i" : [
        [1, 2, 3, 4, 5],
        [3],
        [3],
        [3],
        [1, 2, 3, 4, 5]
    ],
    "j" : [
        [1, 2, 3, 4, 5],
        [3],
        [3],
        [1, 3],
        [2, 3]
    ],
    "k" : [
        [1, 4],
        [1, 3],
        [1, 2],
        [1, 3],
        [1, 4]
    ],
    "l" : [
        [1],
        [1],
        [1],
        [1],
        [1, 2, 3]
    ],
    "m" : [
        [1, 5],
        [1, 2, 4, 5],
        [1, 3, 5],
        [1, 5],
        [1, 5]
    ],
    "n" : [
        [1, 5],
        [1, 2, 5],
        [1, 3, 5],
        [1, 4, 5],
        [1, 5]
    ],
    "o" : [
        [2, 3, 4],
        [1, 5],
        [1, 5],
        [1, 5],
        [2, 3, 4]
    ],
    "p" : [
        [1, 2, 3, 4],
        [1, 5],
        [1, 2, 3, 4],
        [1],
        [1]
    ],
    "q" : [
        [3],
        [2, 4],
        [1, 3, 5],
        [2, 4],
        [3, 5]
    ],
    "r" : [
        [1, 2, 3, 4],
        [1, 5],
        [1, 2, 3, 4],
        [1, 3],
        [1, 4, 5]
    ],
    "s" : [
        [2, 3, 4, 5],
        [1],
        [2, 3, 4],
        [5],
        [1, 2, 3, 4]
    ],
    "t" : [
        [1, 2, 3, 4, 5],
        [3],
        [3],
        [3],
        [3]
    ],
    "u" : [
        [1, 5],
        [1, 5],
        [1, 5],
        [1, 5],
        [2, 3, 4]
    ],
    "v" : [
        [1, 5],
        [1, 5],
        [1, 5],
        [2, 4],
        [3]
    ],
    "w" : [
        [1, 5],
        [1, 5],
        [1, 3, 5],
        [1, 2, 4, 5],
        [1, 5]
    ],
    "x" : [
        [1, 5],
        [2, 4],
        [3],
        [2, 4],
        [1, 5]
    ],
    "y" : [
        [1, 5],
        [2, 4],
        [3],
        [3],
        [3]
    ],
    "z" : [
        [1, 2, 3, 4, 5],
        [4],
        [3],
        [2],
        [1, 2, 3, 4, 5]
    ],
}


def add_alphabet(coordinates, output):
    for i in range(5):
        x = coordinates[i]
        for j in range(6):
            if j in x:
                output[i].append("*")
            else:
                output[i].append(" ")
        
    return output


word = input('Enter a word - ').lower().strip()

while True:
    if not word.isalpha():
        print("Sorry, but you need to enter a valid word containing only letters!")
        print(" ")
        word = input("Enter a word - ").lower().strip()
    else:
        break

output = [[], [], [], [], []]

for letter in word:
    output = add_alphabet(alphabets[letter], output)

for line in output:
    print(''.join(line))

In this code, I am keeping each of the 5 lines in a buffer before print, updating it with values from each alphabet from the input and printing at the end.

Output:

Enter a word - Hi
 *   * *****
 *   *   *  
 *****   *  
 *   *   *  
 *   * *****
Zero
  • 1,807
  • 1
  • 6
  • 17
0

Same kind of idea as proposed by others. The key concept here is to have a map of values (where the asterisks are to be) for each letter.

Then you need to build a list that allows you to iterate over each "row" of the "enlarged" letters.

Something like this:

LMAP = {
    'a': [[3], [2, 4], [1, 2, 3, 4, 5], [1, 5], [1, 5]],
    'b': [[1, 2, 3, 4], [1, 5], [1, 2, 3, 4], [1, 5], [1, 2, 3, 4]],
    'c': [[2, 3, 4, 5], [1], [1], [1], [2, 3, 4, 5]],
    'd': [[1, 2, 3, 4], [1, 5], [1, 5], [1, 5], [1, 2, 3, 4]],
    'e': [[1, 2, 3, 4, 5], [1], [1, 2, 3, 4, 5], [1], [1, 2, 3, 4, 5]],
    'f': [[1, 2, 3, 4, 5], [1], [1, 2, 3, 4, 5], [1], [1]],
    'g': [[2, 3, 4, 5], [1], [1, 3, 4, 5], [1, 5], [2, 3, 4, 5]],
    'h': [[1, 5], [1, 5], [1, 2, 3, 4, 5], [1, 5], [1, 5]],
    'i': [[1, 2, 3, 4, 5], [3], [3], [3], [1, 2, 3, 4, 5]],
    'j': [[1, 2, 3, 4, 5], [3], [3], [1, 3], [2, 3]],
    'k': [[1, 4], [1, 3], [1, 2], [1, 3], [1, 4]],
    'l': [[1], [1], [1], [1], [1, 2, 3, 4]],
    'm': [[1, 5], [1, 2, 4, 5], [1, 3, 5], [1, 5], [1, 5]],
    'n': [[1, 5], [1, 2, 5], [1, 3, 5], [1, 4, 5], [1, 5]],
    'o': [[2, 3, 4], [1, 5], [1, 5], [1, 5], [2, 3, 4]],
    'p': [[1, 2, 3, 4], [1, 5], [1, 2, 3, 4], [1], [1]],
    'q': [[3], [2, 4], [1, 5], [2, 4], [3, 5]],
    'r': [[1, 2, 3, 4], [1, 5], [1, 2, 3, 4], [1, 3], [1, 4, 5]],
    's': [[2, 3, 4, 5], [1], [2, 3, 4], [5], [1, 2, 3, 4]],
    't': [[1, 2, 3, 4, 5], [3], [3], [3], [3]],
    'u': [[1, 5], [1, 5], [1, 5], [1, 5], [2, 3, 4]],
    'v': [[1, 5], [1, 5], [1, 5], [2, 4], [3]],
    'w': [[1, 5], [1, 5], [1, 3, 5], [1, 2, 4, 5], [1, 5]],
    'x': [[1, 5], [2, 4], [3], [2, 4], [1, 5]],
    'y': [[1, 5], [2, 4], [3], [3], [3]],
    'z': [[1, 2, 3, 4, 5], [4], [3], [2], [1, 2, 3, 4, 5]],
}

def lmap(lst):
    m = []
    for r in lst:
        line = [' ']*5
        for p in r:
            line[p-1] = '*'
        m.append(line)
    return m

word = 'stackoverflow'

patterns = [lmap(LMAP[letter]) for letter in word]

for row in range(5):
    print(' '.join(''.join(p[row]) for p in patterns))

Output:

 **** *****   *    **** *  *   ***  *   * ***** ****  ***** *      ***  *   *
*       *    * *  *     * *   *   * *   * *     *   * *     *     *   * *   *
 ***    *   ***** *     **    *   * *   * ***** ****  ***** *     *   * * * *
    *   *   *   * *     * *   *   *  * *  *     * *   *     *     *   * ** **
****    *   *   *  **** *  *   ***    *   ***** *  ** *     ****   ***  *   *
DarkKnight
  • 19,739
  • 3
  • 6
  • 22
0

Well, the above answer by "DarkKnight" looks to be the most optimised one, but this was fun, I just wanted to fix your code in the way you have written. Heres the fixed code (just fixed, not optimised ).

def a():
    row1 = [3]
    row2 = [2, 4]
    row3 = [1, 2, 3, 4, 5]
    row4 = [1, 5]
    row5 = [1, 5]
    return [row1, row2, row3, row4, row5]
    
def b():
    row1 = [1, 2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 2, 3, 4]
    row4 = [1, 5]
    row5 = [1, 2, 3, 4]
    return [row1, row2, row3, row4, row5]
    
def c():
    row1 = [2, 3, 4, 5]
    row2 = [1]
    row3 = [1]
    row4 = [1]
    row5 = [2, 3, 4, 5]
    return [row1, row2, row3, row4, row5]

def d():
    row1 = [1, 2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 5]
    row4 = [1, 5]
    row5 = [1, 2, 3, 4]
    return [row1, row2, row3, row4, row5]
    
def e():
    row1 = [1, 2, 3, 4, 5]
    row2 = [1]
    row3 = [1, 2, 3, 4, 5]
    row4 = [1]
    row5 = [1, 2, 3, 4, 5]
    return [row1, row2, row3, row4, row5]

def f():
    row1 = [1, 2, 3, 4, 5]
    row2 = [1]
    row3 = [1, 2, 3, 4, 5]
    row4 = [1]
    row5 = [1]
    return [row1, row2, row3, row4, row5]

def g():
    row1 = [2, 3, 4, 5]
    row2 = [1]
    row3 = [1, 3, 4, 5]
    row4 = [1, 5]
    row5 = [2, 3, 4, 5]
    return [row1, row2, row3, row4, row5]

def h():
    row1 = [1, 5]
    row2 = [1, 5]
    row3 = [1, 2, 3, 4, 5]
    row4 = [1, 5]
    row5 = [1, 5]
    return [row1, row2, row3, row4, row5]

def i():
    row1 = [1, 2, 3, 4, 5]
    row2 = [3]
    row3 = [3]
    row4 = [3]
    row5 = [1, 2, 3, 4, 5]
    return [row1, row2, row3, row4, row5]

def j():
    row1 = [1, 2, 3, 4, 5]
    row2 = [3]
    row3 = [3]
    row4 = [1, 3]
    row5 = [2, 3]
    return [row1, row2, row3, row4, row5]

def k():
    row1 = [1, 4]
    row2 = [1, 3]
    row3 = [1, 2]
    row4 = [1, 3]
    row5 = [1, 4]
    return [row1, row2, row3, row4, row5]

def l():
    row1 = [1]
    row2 = [1]
    row3 = [1]
    row4 = [1]
    row5 = [1, 2, 3]
    return [row1, row2, row3, row4, row5]

def m():
    row1 = [1, 5]
    row2 = [1, 2, 4, 5]
    row3 = [1, 3, 5]
    row4 = [1, 5]
    row5 = [1, 5]
    return [row1, row2, row3, row4, row5]

def n():
    row1 = [1, 5]
    row2 = [1, 2, 5]
    row3 = [1, 3, 5]
    row4 = [1, 4, 5]
    row5 = [1, 5]
    return [row1, row2, row3, row4, row5]

def o():
    row1 = [2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 5]
    row4 = [1, 5]
    row5 = [2, 3, 4]
    return [row1, row2, row3, row4, row5]

def p():
    row1 = [1, 2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 2, 3, 4]
    row4 = [1]
    row5 = [1]
    return [row1, row2, row3, row4, row5]

def q():
    row1 = [3]
    row2 = [2, 4]
    row3 = [1, 3, 5]
    row4 = [2, 4]
    row5 = [3, 5]
    return [row1, row2, row3, row4, row5]

def r():
    row1 = [1, 2, 3, 4]
    row2 = [1, 5]
    row3 = [1, 2, 3, 4]
    row4 = [1, 3]
    row5 = [1, 4, 5]
    return [row1, row2, row3, row4, row5]

def s():
    row1 = [2, 3, 4, 5]
    row2 = [1]
    row3 = [2, 3, 4]
    row4 = [5]
    row5 = [1, 2, 3, 4]
    return [row1, row2, row3, row4, row5]

def t():
    row1 = [1, 2, 3, 4, 5]
    row2 = [3]
    row3 = [3]
    row4 = [3]
    row5 = [3]
    return [row1, row2, row3, row4, row5]

def u():
    row1 = [1, 5]
    row2 = [1, 5]
    row3 = [1, 5]
    row4 = [1, 5]
    row5 = [2, 3, 4]
    return [row1, row2, row3, row4, row5]

def v():
    row1 = [1, 5]
    row2 = [1, 5]
    row3 = [1, 5]
    row4 = [2, 4]
    row5 = [3]
    return [row1, row2, row3, row4, row5]

def w():
    row1 = [1, 5]
    row2 = [1, 5]
    row3 = [1, 3, 5]
    row4 = [1, 2, 4, 5]
    row5 = [1, 5]
    return [row1, row2, row3, row4, row5]

def x():
    row1 = [1, 5]
    row2 = [2, 4]
    row3 = [3]
    row4 = [2, 4]
    row5 = [1, 5]
    return [row1, row2, row3, row4, row5]

def y():
    row1 = [1, 5]
    row2 = [2, 4]
    row3 = [3]
    row4 = [3]
    row5 = [3]
    return [row1, row2, row3, row4, row5]

def z():
    row1 = [1, 2, 3, 4, 5]
    row2 = [4]
    row3 = [3]
    row4 = [2]
    row5 = [1, 2, 3, 4, 5]
    return [row1, row2, row3, row4, row5]

def get_cordinates_of_char(char):
    match(char):
        case 'a' : return a()
        case 'b' : return b()
        case 'c' : return c()
        case 'd' : return d()
        case 'e' : return e()
        case 'f' : return f()
        case 'g' : return g()
        case 'h' : return h()
        case 'i' : return i()
        case 'j' : return j()
        case 'k' : return k()
        case 'l' : return l()
        case 'm' : return m()
        case 'n' : return n()
        case 'o' : return o()
        case 'p' : return p()
        case 'q' : return q()
        case 'r' : return r()
        case 's' : return s()
        case 't' : return t()
        case 'u' : return u()
        case 'v' : return v()
        case 'w' : return w()
        case 'x' : return x()
        case 'y' : return y()
        case 'z' : return z()


def print_line(line_cord):
    for cord in range(line_cord[-1]+1):
        print("*", end="") if cord in line_cord else  print(" ", end="")
    print("")


word = "helloworld"
word_split = list(word)
each_char_length = 6
word_length = len(word_split)

full_word_cord_array = []
for each_alphabet in word_split:
    full_word_cord_array.append(get_cordinates_of_char(each_alphabet))

for row in range(5):
    new_cords = []
    for col in range(word_length):
        new_values_array = [(num + (col *  each_char_length)) for num in full_word_cord_array[col][row]]
        new_cords.append(new_values_array)
    flattened_array = [element for sublist in new_cords for element in sublist]
    print_line(flattened_array)
Aravind Pillai
  • 739
  • 7
  • 21