Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python halp

Name: Anonymous 2008-12-10 15:52

I get the error:
Traceback (most recent call last):
  File "nigger.py", line 94, in <module>
    logV[k]=tp[0]
IndexError: index out of bounds

From the following code:
A=0.
a=0.
pFile = open("pFile.data","r")
logV = empty(nB,float);
logpE = empty(nB,float); logpN = empty(nB,float)
logpW = empty(nB,float); logpS = empty(nB,float)
logp = empty(nB,float)
for k in range(nB):
    line = pFile.readline()
    numbers = line.split()
    n = len(numbers); tp = empty(n,float)
    for i in range(n):
        tp[i] = float(numbers[i])
    logV[k]=tp[0]
    logpE[k]=tp[1]; logpN[k]=tp[2]
    logpW[k]=tp[3]; logpS[k]=tp[4]
    logp[k]=tp[5]
    A = A+logp[k]+logV[k]
   
B = A/nB
for k in range(nB):
    line = pFile.readline()
    numbers = line.split()
    n = len(numbers); tp = empty(n,float)
    for i in range(n):
        tp[i] = float(numbers[i])
    logV[k]=tp[0] #---------------------line 94
    logpE[k]=tp[1]; logpN[k]=tp[2]
    logpW[k]=tp[3]; logpS[k]=tp[4]
    logp[k]=tp[5]
    a = a+(logp[k]+logV[k]-B)**2

The first bit of code doesn't produce this error, so why does the second?

Name: Anonymous 2008-12-10 15:56

0/10

Name: Anonymous 2008-12-10 15:58

IndentationError: expected an indented block

Name: Anonymous 2008-12-10 15:58

>>1
Ask the Abelson, not us.

Name: Anonymous 2008-12-10 16:02

Note that I have no idea what I'm doing. I only know a few Python commands. Most of this code is from the professor; I've just been copy-pasting where I need it. I don't understand why this particular copypasta produces an error.

Name: Anonymous 2008-12-10 16:04

Try learning Python first.

Name: Anonymous 2008-12-10 16:05

Your problem is not a program that produces an error. Your problem is the way that program came to be.

Name: Anonymous 2008-12-10 16:06

>>6
no u

Name: Trollbot9000 2009-07-01 10:05


Copypasta BSD code into the appropriate machine  code It actually  costs 5 or  10 for anal  retentive neocons Wrong.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List