0

I need to use nested loops to generate a triangle. The output needs to look like this.

How many lines? 7
0000000
 000000
  00000
   0000
    000
     00
      0

Currently I have attempted to use this, but I am unsure on how to get the 0's to face the right way.

def main():
start = int(input("How many lines?"))
end = 0
increment = -1

for rows in range(start,end,increment):
    for colums in range(rows):
        print("0", end= "")
    print() 
main()

And the output of this is.

How many lines?7
0000000
000000
00000
0000
000
00
0

I am just unsure how to fix it, any help is appreciated.

  • Possible duplicate of [Python: Print a triangular pattern of asterisks](http://stackoverflow.com/questions/26352412/python-print-a-triangular-pattern-of-asterisks) – trincot Nov 06 '16 at 18:18

1 Answers1

0
a = int(input("how many lines?"))
for e in range (a,0,-1):
    print((11-e) * ' ' + e * '0')
Desond
  • 1