Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'part,': 0.09; 'python:': 0.09; 'rows': 0.09; 'times,': 0.13; 'represents': 0.15; "'*'": 0.16; 'outputs': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject:program': 0.16; 'string': 0.17; 'wrote:': 0.17; 'string,': 0.17; "i've": 0.23; 'idea': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'far,': 0.29; 'prints': 0.29; 'print': 0.32; 'to:addr:python-list': 0.33; 'code:': 0.33; 'there': 0.35; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'space': 0.39; 'received:192.168': 0.40; 'first': 0.61; 'between': 0.63; 'p.s.': 0.63; 'email addr:gmail.com': 0.63; 'note:': 0.64; 'border': 0.65; 'middle': 0.66; 'hey,': 0.72; 'asterisk': 0.84; 'multiply': 0.84; 'square,': 0.84 Date: Wed, 12 Dec 2012 12:18:29 -0500 From: Mitya Sirenef User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Hollow square program References: <1aa414f0-1e4c-424b-abc6-8e681631788b@googlegroups.com> In-Reply-To: <1aa414f0-1e4c-424b-abc6-8e681631788b@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355332724 news.xs4all.nl 6990 [2001:888:2000:d::a6]:50182 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34700 On 12/12/2012 11:48 AM, siimnurges@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/