The problem is to follow this pattern, for input 1<=n<10:
Input:7
Output:
1******
12*****
123****
1234***
12345**
123456*
1234567
and this is my code:
a=[]
n=int(input('Enter a number between 1 and 9 inclusive: '))
if n>9 or n<1:
pass
else:
for i in range(1,n+1):
a.append(i)
a=str(a)
a=a[0:-1]
a=a[1:]
a=a.replace(", ","")
for j in range(1,n+1):
print(a[0:j]+"*"*(n-j))
But it doesn’t work. What could be wrong with it?