Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34708
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Hollow square program |
| Date | 2012-12-12 18:44 +0100 |
| Organization | None |
| References | <1aa414f0-1e4c-424b-abc6-8e681631788b@googlegroups.com> <mailman.779.1355331602.29569.python-list@python.org> <1ab10bb2-9036-414b-af24-0a3d2d32c9d2@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.785.1355334206.29569.python-list@python.org> (permalink) |
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 first and last row have an extra space between the asterisks. For the square to look like a square you need to add these to the other rows (and thus s2), too. Also note that your code prints a minimum of two rows.
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