Following script will create the triangle using alphabets. for using no comment the list a and change a[i] to i. To print in reverse order interchange the for loop parameters.
Note: if you dont specify the , in the print statement then it will print the values of row in next line instead of printing continuously in same row.
Script:
a = ['a','b','c','d','e','f', 'g','h','i']
for j in range(0,8,1):
print'\n'
for i in range(8,0,-1):
if i>j:
print a[j],
Output of the program will be :
a a a a a a a a
b b b b b b b
c c c c c c
d d d d d
e e e e
f f f
g g
Note: if you dont specify the , in the print statement then it will print the values of row in next line instead of printing continuously in same row.
Script:
a = ['a','b','c','d','e','f', 'g','h','i']
for j in range(0,8,1):
print'\n'
for i in range(8,0,-1):
if i>j:
print a[j],
Output of the program will be :
a a a a a a a a
b b b b b b b
c c c c c c
d d d d d
e e e e
f f f
g g