Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42458
| Date | 2013-04-01 07:53 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: How to do this? |
| References | <83a54022-576d-465b-b6bd-7e21cde59d99@googlegroups.com> <mailman.4051.1364813918.2939.python-list@python.org> <29fa109e-8ed0-4b1b-a9c0-473e2bace687@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4054.1364817250.2939.python-list@python.org> (permalink) |
On 04/01/2013 07:08 AM, Ana Dionísio wrote:
> [0 0 0 0 0.17 0.17 0.17 0.17 0 0 0 0.17 0.17 0.17 0 0 0 0 0 0 0]
I'd do
res = "[0 0 0 0 0.17 0.17 0.17 0.17 0 0 0 0.17 0.17 0.17 0 0 0 0 0 0 0]"
Unless there's a pattern you're trying to accomplish (like maybe next
time you want to do "it" for a list of two million items), there's
little point in writing code to do what you've already predetermined.
And if there is a pattern, you'd probably better let us know.
But if it's for fun,
vt = [0] * 21
for index, val in enumerate(vt):
if 3<index<8 or 10<index<14:
vt[index] = 0.17
or
vt = [0] * 21
for index, val in enumerate(vt):
if index in (4,5,6,7,11,12,13):
vt[index] = 0.17
--
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to do this? Ana Dionísio <anadionisio257@gmail.com> - 2013-04-01 03:14 -0700
Re: How to do this? Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2013-04-01 12:58 +0200
Re: How to do this? Ana Dionísio <anadionisio257@gmail.com> - 2013-04-01 04:08 -0700
Re: How to do this? Peter Otten <__peter__@web.de> - 2013-04-01 13:32 +0200
Re: How to do this? Dave Angel <davea@davea.name> - 2013-04-01 07:53 -0400
Re: How to do this? Ana Dionísio <anadionisio257@gmail.com> - 2013-04-01 04:08 -0700
Re: How to do this? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-04-01 13:28 +0100
csiph-web