Robotics & Artificial Intelligence

Write Python code to display the following pattern:

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

Python Control Flow

2 Likes

Answer

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

Output

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

Answered By

1 Like


Related Questions