vendredi 2 novembre 2018

Pick random integers from list elements of same index and generate a list

I have two lists a & b and I need to pick a random element of a[i] and b[i] and generate z.

a = [1, 0, 1, 1, 0, 1]
b = [1, 1, 0, 1, 0, 0]

z = [1, 0, 1, 1, 0, 0]

I used the below mentioned code:

import random
z = []
for i in range(6):
    value = random(a[i],b[i])
    z.append(value)
print z

and I get the following error:

TypeError: 'module' object is not callable




Aucun commentaire:

Enregistrer un commentaire