Home > database >  Unable to print the following basic pattern
Unable to print the following basic pattern

Time:10-07

I want to print This pattern.

1 2 3 4

1 2 3

1 2

1

So I implement this

 x = int(input("Enter number of row:\n"))

 for i in range(1,x 1):

     for j in range(1,x 1):

         print(j,end=" ")

     print() 

but I don't get as showed in question I know that no. of column have to decreased by one but how ever I can not managed to do that. please tell me what I have to do in order to solve the question.

CodePudding user response:

This is how i would do it:

x = int(input("Enter number of row:\n"))
for i in range(1,x 1):
    print(*range(1,x 1))
    x-=1
  • Related