0

Number pattern(iterative statements)

N = int(input("enter n value:")) for i in range(1,N+1): for k in range(N,i,-1): print(" ", end =' ') for j in range(1,i+1): print(j, end =' ') for m in range(i-1,0,-1): print(m, end =' ') print()

12th Feb 2023, 2:36 PM
Rakshitha Arun
Rakshitha Arun - avatar
1 Answer
+ 3
for <i> loop repeats <N> times for <k> loop prints the spaces to the left of the numbers for <j> loop prints the numbers in ascending sequence for <m> loop prints the numbers in descending sequence The last call to print() simply puts a line break + Please tag Python rather than "how it works?"
12th Feb 2023, 3:48 PM
Ipang