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 -
* * *****
* * *
***** *
* * *
* * *****