+ 1
In python, How can i print sequence of n nos in first line,n-1 in second line and so on?
I would like to print like if given i=3,then the output should be like 123 12 1
2 ответов
+ 6
[print(*list(range(1,x+1)),sep='') for x in range(1,int(input())+1)[::-1]]
+ 3
# Function to demonstrate printing pattern of numbers
def numpat(n):
# initialising starting number
num = 1
# outer loop to handle number of rows
for i in range(0, n):
# re assigning num
num = 1
# inner loop to handle number of columns
# values changing acc. to outer loop
for j in range(0, i+1):
# printing number
print(num, end=" ")
# incrementing number at each column
num = num + 1
# ending line after each row
print("\r")
# Driver code
n = 3
numpat(n)