Given an integer N, write a program to print pattern "8" in (2*N + 1) rows and N columns, similar to the pattern shown below
* * * * *
* *
* *
* *
* *
* * * * *
* *
* *
* *
* *
* * * * *
columns = int(input("Enter a number of columns: "))
rows = 2*columns + 1
for row in range(rows):
if row == 0 or row == rows - 1 or row == (rows - 1)/2:
print(columns*"*")
else:
print()
print("*"+" "*(columns-2)+"*")
Comments
Leave a comment