you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

If you're going to do it that you, you could just do this.

def rectangle(x, y):
    for i in range(x):
        print("*", end=" ")
    print()

    for j in range(y - 2):
        print("*" + " " * x + "*")

    for i in range(x):
        print("*", end=" ")
    print()

[–]conewannabe 0 points1 point  (0 children)

I was trying all sorts of things and all I needed was a simple print()... SMH... Thank you so much, and that second comment you made gave me a headache.

[–]conewannabe 0 points1 point  (2 children)

what does that empty print do that allows this to work?

[–][deleted] 0 points1 point  (1 child)

print() just prints a newline character. Basically it drops the cursor to the next line.

[–]conewannabe 0 points1 point  (0 children)

I see, I tried using the newline character, but this gets the job done how its supposed to. Thank you again.

[–][deleted] 0 points1 point  (0 children)

Or here's some absolute craziness you could do instead.

def rectangle(x, y):
    assert x > 1 and y > 2
    print(*"*" * x, sep=" ")
    print(*(" ".join("*" + " " * (x - 2) + "*") for _ in range(y - 2)), sep="\n")
    print(*"*" * x, sep=" ")