Feb-18-2022, 02:06 PM
Hello guys,
I need a help with my python code and tell me what is wrong here.
Thank you so much
I need a help with my python code and tell me what is wrong here.
tum=[] for i in range(400): tum.append(i) rassal=[] rassal=random.sample(range(400), 200) new_list = [x for x in tum if (x not in rassal)] matrix3=[] fileHandle.write("[") for y in range(80): w=[] for i in rassal: z=5 w.append(z) for k in new_list: kk=((round(random.uniform(5,10)))) w.append(kk) matrix3.append(w) for w in matrix3: w = [str(number) for number in w] w = ",".join(w) fileHandle.write("["+w+"],\n") fileHandle.write("];\n")What I am trying to do here, I want to create 80 row and 400 coloumn matrix. For column indices , I make a list by randomly generated data and in those indices I want to assign a random value between 5 and 10. For the other values , which hold in rassal list , I want to assign 5. However, in the output for each row first 200 comounb it assings 5, last 200 coloumn random value. This is not what I need . Can you help me what I am doing wrong here ?
Thank you so much