Robotics & Artificial Intelligence

Write Python code to display the following pattern:

5 4 3 2 1
5 4 3 2
5 4 3
5 4
5

Python Control Flow

2 Likes

Answer

for i in range(1, 6):
    
    for j in range(5, i - 1, -1):
        print(j, end=" ")
    
    print()

Output

5 4 3 2 1 
5 4 3 2 
5 4 3 
5 4 
5 

Answered By

1 Like


Related Questions