dimanche 29 juillet 2018

Python 27. how to stick data to correct tuple list in list

First of all see this code. Now i use python 27 on Psychopy 2(1.85.4)

before explain my problem introduce my list and datatype

1. oneman = 252 of [a,b,c,d]
2. bincan = [(0, []), (1, []), (2, []), (3, []), (4, []), (5, []), (6, [])]

The problem was identified at last function, oneman[0][0] = 'a' so i want use the 'a' for indexing bincan number. and stick the data 'd' to each list. but the result was correct result of logic is go to all bincan list like

fucking result [(0, [(d)]), (1, [d]), (2, [d]), (3, [d]), (4, [d]), (5, [d]), (6, [d])]

please where is the problem in this logic. def clear (datum) : Cdata = [] for i in datum: Cdata.append(i[0]) Cdata.append(i[1]) Cdata.append(i[3]) Cdata.append(i[4]) return Cdata

def reline(data):
    alpha = np.array(data)
    postC = alpha.reshape((252, 4))
    return postC.tolist()
oneman = reline(clear(fp[1]))

def bincan(listnum):
    alpha, beta = [] ,[]
    ceta = range(listnum)
    for i in range(listnum) :
        alpha.append(beta)
    return zip(ceta, alpha)
pillcan = bincan(7)


def sieve(datum):
    for i in datum:
        if i[0] == 0:
            pillcan[0][1].append(i[3])
    return pillcan

Aucun commentaire:

Enregistrer un commentaire