'list indices must be integers, not tuple' error in newbie script
Hi expers!!
Im a new user of SAGE. Right now im writing a script that plot 'N' random lines of lenght=1 in a rectangle of b*h center in axes. The code is shhow below:
N=float(raw_input('Número de rectas aleatóreos (N)?:\n'))
b=float(raw_input('Base del rectángulo (b>1)?:\n'))
h=float(raw_input('Altura del cuadrado (h>1)?:\n'))
uniforme_x=RealDistribution('uniform',[-b/2,b/2])
uniforme_y=RealDistribution('uniform',[-h/2,h/2])
lista_x=[uniforme_x.get_random_element() for j in srange(N)]
lista_y=[uniforme_y.get_random_element() for j in srange(N)]
lista_xy = zip(lista_x , lista_y)
lineas=[]
d2=1*1*2
for j in lista_xy:
x1 = lista_xy[j][0]
y1 = lista_xy[j][1]
while d2>1*1:
x2 = uniforme_x.get_random_element()
y2 = uniforme_x.get_random_element()
d2=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)
lineas.append(line([lista_xy[j],(x2,y2)]))
grafico=sum(lineas)
grafico.show()
When i execute this code I get the error messege 'list indices must be integers, not tuple'.
Whats the problem?
Waiting for your answers.
Thanks a lot!