I'm trying to make a shape with Python using the console output.
My code for printing shape with no spaces is as
tri=int(input("enter size : "))
Which results in the output
enter size : 6
******
*****
****
***
**
*
However, the shape should look like this
******
* *
* *
* *
*
there is your solution:)
n=int(input("enter size : "))
for row in range(0,n):
for col in range(0,n):
if row == 0 or col == 0 or row==n-col-1:
print("*", end="")
else:
print(end=" ")
print()
example input:
enter size : 6
******
* *
* *
* *
**
*
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.