Reputation: 11
Size = int(input("what is the size of the box "))
def Stars(Size):
for x in range(0, Size):
for y in range(0, Size):
print("*",end="")
Stars()
OUTPUT (if the size of the box was 4)
****
*==*
*==*
****
Upvotes: 0
Views: 431
Reputation: 11
def Stars(x = int(input("Enter size of box"))):
print("*" * x)
for i in range(1, x - 1):
print("*"+"="*(x - 2)+ "*")
print("*"* x)
Stars()
Upvotes: 0
Reputation: 452
Try this lambda function
box = lambda columns: [print(('*'*columns if c==0 or c==columns-1 else '*'+'='*(columns-2)+'*')) for c in range(columns)]
Upvotes: 0
Reputation: 3396
for the first and last line, they should be outside the loop. Then you can create the loop normally,
def stars(x):
print('*'*x)
for i in range(1,x-1):
print('*'+'='*(x-2)+'*')
print('*'*x)
stars(4)
Upvotes: 1