KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

Write Python code to display the following pattern:

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

Python Control Flow

2 Likes

Answer

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

Output

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

Answered By

2 Likes


Related Questions