Python Forum

Full Version: pattern question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
'''
5 4 3 2 1
5 4 3 2 1
5 4 3 2 1
5 4 3 2 1
5 4 3 2 1
'''
'''I am trying to print the pattern'''
n = int(input("Please enter the number of times "))
for i in range(n):
    for j in range(n, 0 -1):
        print(j, end = " ")
    print()
Output:
Please enter the number of times 3 Process finished with exit code 0
I am not looking for solution but please tell me why is that, it is not printing the output. In regards to solution, I am still working on it.

I made a big time small mistake, Thank you
for j in range(n, 0 -1):
A comma is missing:
for j in range(n, 0, -1):
range accepts one, two or three arguments.

This code: range(n, 0 -1)
Is evaluated to: range(n, -1)