Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34706
| References | <1aa414f0-1e4c-424b-abc6-8e681631788b@googlegroups.com> <mailman.779.1355331602.29569.python-list@python.org> <1ab10bb2-9036-414b-af24-0a3d2d32c9d2@googlegroups.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-12-12 10:35 -0700 |
| Subject | Re: Hollow square program |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.784.1355333752.29569.python-list@python.org> (permalink) |
On Wed, Dec 12, 2012 at 10:22 AM, <siimnurges@gmail.com> wrote: > Well, I did some modifications and got a hollow square, but the columns aren't perfectly aligned with the rows (at least if input is 5. Thanks for the help :) > > rows = int(input()) > s1="* "*rows > s2="*"+(rows-2)*" "+"*" > print(s1) > for s in range(rows-2): > print(s2) > print(s1) The (rows-2)*" " in s2 is only enough spaces to account for the (rows-2) inner * characters in s1. You also need additional spaces in s2 to match up with for the (rows-1) space characters in between the * characters in s1.
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