Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34700
| 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 | <msirenef@lightbird.net> |
| 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 <msirenef@lightbird.net> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.780.1355332724.29569.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
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/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Hollow square program siimnurges@gmail.com - 2012-12-12 08:48 -0800
Re: Hollow square program Chris Angelico <rosuav@gmail.com> - 2012-12-13 03:59 +1100
Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:22 -0800
Re: Hollow square program Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-12 10:35 -0700
Re: Hollow square program Peter Otten <__peter__@web.de> - 2012-12-12 18:44 +0100
Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:52 -0800
Re: Hollow square program Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-12-12 23:47 +0000
Re: Hollow square program Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-13 00:12 +0000
Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:52 -0800
Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:22 -0800
Re: Hollow square program Mitya Sirenef <msirenef@lightbird.net> - 2012-12-12 12:18 -0500
Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:25 -0800
Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:25 -0800
csiph-web