0

Hi, I have generated an array of random numbers and I'm trying to then write this array to a .txt file but the code I have written doesn't seem to do this correctly. Any help on this would be great. Here is what I have so far:

import numpy as N

import random

def main():

n=10

size=1500

initial=N.zeros([n,3], dtype=N.float64)

filename="initialpositions.txt"

for i in range(n):

for j in range(size):

initial[i,j]=random.randrange(0,size)

file=open(filename,'w')

file.write(initial)

file.close()