0
a=" "*j+"*"*i+" "*j please tell this logic
i=1 j=2 while i>=1: a=" "*j+"*"*i+" "*j print(a) i=i+2 j=j-1 if i>5: break i=3 j=1 while i>=1: a=" "*j+"*"*i+" "*j print(a) i=i-2 j=j+1 OUTPUT * *** ***** *** *
1 Answer
+ 1
a=" "*j+"*"*i+" "*j
" " * j is a multiplication of spaces " " by j ,
if j == 2 it will print 2 spaces.
"*"*i multiplication of "*" by i.
if i == 1 it will print one "*".
+ is used to concatenate left spaces " " with "*" and right spaces " "
first loop decreases the number of spaces and increases the number of "*"
second loop does the opposite.
replace a=" "*j+"*"*i+" "*j
with
a="x"*j+"*"*i+"x"*j
see what happens to x.