How to do this?

Ana Dionísio anadionisio257 at gmail.com
Mon Apr 1 06:14:15 EDT 2013


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



More information about the Python-list mailing list