For me it smells like homework. So I provide one partial way to do it - how to print rectangle, but without center.
def do_rectangle(height=5, width=7, characters='GIS'): inner_width = len(characters) * (width - 2) + width - 1 for i in range(height): if i in (0, height-1): print(' '.join(characters for i in range(width))) else: print(f'{characters}{" "*inner_width}{characters}') do_rectangle() do_rectangle(height=5, width=5, characters='*')
Output:GIS GIS GIS GIS GIS GIS GIS
GIS GIS
GIS GIS
GIS GIS
GIS GIS GIS GIS GIS GIS GIS
* * * * *
* *
* *
* *
* * * * *
It's matter of defensiveness how to deal with negative width.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.