The goal is to write a program that can print this output
Enter a number: 4
*00000*
**000**
***0***
*******
These are what I’m currently working with:
row = int(input('Enter number of rows required: '))
for i in range(row,0,-1):
for j in range(row-i):
print('*', end='')
for j in range(2*i-1):
print('0',end='')
print() # printing new line
And this is the current output:
0000000
*00000
**000
***0
I can’t figure out what to change to have the correct output
>Solution :
you can use f-string and siple nth number from the formula a + (n-1)*d
row = int(input('Enter number of rows required: '))
for i in range(row):
print(f'{"*"*(i+1)}{"0"*(2*(row-i-1) - 1)}{"*"*(i+1)}')