lundi 30 janvier 2017

python for-loop only executes once?

def Vin(t):
    inputs = []
    for i in range (1000):
        if (-1)**(np.floor( 2 * t[i] )) == 1:
            Vin = (1)
            inputs.append(Vin)
        else:
            Vin = (-1)
            inputs.append(Vin)

        return inputs

when i use this function on a range of t values i only get one result,

i.e.

input1=Vin(tpoints)
print (input1)

only gives [1], whereas i want the function to do it for every t value.

thanks

Aucun commentaire:

Enregistrer un commentaire