Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42451

How to do this?

Newsgroups comp.lang.python
Date 2013-04-01 03:14 -0700
Message-ID <83a54022-576d-465b-b6bd-7e21cde59d99@googlegroups.com> (permalink)
Subject How to do this?
From Ana Dionísio <anadionisio257@gmail.com>

Show all headers | View raw


So I have this script:

"
from numpy import array

vt=[0]*20
vt = array(vt, dtype=dict)

for t in range(20):
    if t == 4:
        vt[t]=1

    else:
        vt[t]=0
"

And have this output:

[0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

What I need is when t == 4 I need to put 1 in that position and in the next 3, for example the following output:

[0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]

Do you have any suggestions?


I'm sorry if I can't explain this in a better way, English is not my first language

Thank you

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


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