I am fairly new to array data structures. I am trying to print the below pattern in python.
12345
1234
123
12
1
Here is my code:
a = [1,2,3,4,5]
n = len(a)
for i in range(n, 0, -1):
for j in range(i):
print a[j],
Output: I am getting the correct order. I just can't seem to arrange the answer in the desired format. Any suggestions?
1 2 3 4 5 1 2 3 4 1 2 3 1 2 1