Print the pattern shown in attachment by using loop method in python.
Attachments:
![](https://hi-static.z-dn.net/files/db8/c5db6c3e932d58222fedae12316668b5.png)
Answers
Answered by
5
The Loop Method I Know ;)
Attachments:
![](https://hi-static.z-dn.net/files/d08/82b074a7aace788d09d0f7fd614df92a.jpg)
Answered by
3
The given code is written in Python 3.
n=3
for i in range(n,-n-1,-1):
for _ in range(1,abs(i)+1):
print(" ",end="")
for _ in range(n,abs(i)-1,-1):
print("* ",end="")
print()
Three loops are used here. Outer loop iterates 7 times as there are 7 rows for the pattern. There are two inner loops. First loop prints spaces where necessary and second loop prints stars. A new line is then inserted.
Attachments:
![](https://hi-static.z-dn.net/files/d3a/f5b3ee47c740ba026abe0922c5258a17.png)
![](https://hi-static.z-dn.net/files/db5/7a4b533887d9d5ea60a73e0878d1c6b3.jpg)
Similar questions