On 12/12/2012 11:48 AM, siimnur...@gmail.com wrote:
Hey, I need to write a program that prints out a square, which is empty on the inside. So far, I've
made a program that outputs a square, which is full on the inside.
> P.S. Between every asterisk there needs to be a space(" ")
> Here's my code:
>
> print("Rows: ")
> rows = int(input())
> for i in range(rows):
> for j in range(rows):
> print("* ", end="")
> print("")


Small note: print("") is the same as print()

The general idea is: make a string that represents top/bottom of the
square, make a string for the middle part, print out the first string,
then print out middle part n-2 times, then print out first string again.

Did you know you can multiply strings? e.g.:

space  = ' '
border = '*'
line   = border + space*70

 -m

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to