[Tutor] Need Help on Assignment (fwd)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Aug 24 00:31:52 CEST 2005


[Forwarding to Tutor; next time, please also use Reply-to-All in your
email client.  That way, everyone can help.]


---------- Forwarded message ----------
Date: Tue, 23 Aug 2005 17:19:43 -0500
From: Tom Strickland <tlinux at comcast.net>
To: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
Subject: Re: [Tutor] Need Help on Assignment


>Do you mind if you show us what you've tried so far?
>
>Also, show us the exact syntax error and the stack trace that Python
>reports.  It'll help us to see what's really going on.  Your paraphrase of
>the situation is useful, but it's obscuring information that we need to
>see to be able to duplicate your problem.
>
>If your program is short, just copy-and-paste it into your reply.


Danny,

Here's a copy of the current version of the program and the terminal
output. Hope this helps!

Thank you!

Tom Strickland

***********************************************************************************************************

*_PROGRAM:_*



#!/usr/bin/python2.4

input = open('/home/tom/Python/Input/SPY3.txt', 'r')

N=0

s = 'boo'

date =['hoo']

T = [0,0,0,0,0,0]               #don't know why this is necessary

open = close = hi = lo = vol = [1.0]  #is this necessary?

while s:

    s = input.readline()

    if s == '':break

    s = s[:-2]

    T[N] = s.split(',')

    date[N] = T[N][0]

    open[N] = T[N][1]

    hi[N] = T[N][2]

    lo[N] = T[N][3]

    close[N] = T[N][4]

    vol[N] = T[N][5]

    N+=1

print N

for i in range(N):

    T[i]

    print T[i]

    print date[i], open[i], hi[i], lo[i], close[i], vol[i]

print T[1][2], T[0][0]







*_TERMINAL OUTPUT:_*

*_ _*

[tom at localhost ~]$ cd Python/SourceCode

[tom at localhost SourceCode]$ ./ispy.py

Traceback (most recent call last):

  File "./ispy.py", line 13, in ?

    date[N] = T[N][0]

IndexError: list assignment index out of range

[tom at localhost SourceCode]$




More information about the Tutor mailing list