18 - Write a program in Python to generate the following pattern using nested loops:
1
234
56789
10111213141516
p=1
a=5
k=2
n=3
for i in range(1,5):
for s in range(1,a):
print(end=' ')
for j in range(p,k):
print(j,end='')
print()
a=a-1
p=j+1
k=k+n
n=n+2
Output:
1
234
56789
10111213141516
No comments:
Post a Comment