Please help with problem creating class
member thudfoo
thudfoo at opensuse.us
Sat Apr 18 15:35:22 EDT 2009
Correction:
On 4/18/09, member thudfoo <thudfoo at opensuse.us> wrote:
> On 4/18/09, auzarski2008 at gmail.com <auzarski2008 at gmail.com> wrote:
> > Hi I have been working on a homework assignment that I am having a lot
> > of trouble with. I am so frustrated because every time I think I am
> > getting close to figuring it out there is another problem. If you
> > could look at this and tell me what I am doing wrong I would very much
> > appreciate it....
> >
> > import string
> >
> > from datetime import date
> >
> >
> >
> > class Leaderapplicant:
> >
> >
> >
> > def __init__(self, line):
> >
> > #convert the lines of data into fields and removes
> > \n
> >
> > line = line.rstrip("\n")
> >
> > appname, leadername, start, end = line.split("\t")
> >
>
> [...]
>
>
> >
> > I am using tab separated data in another file that looks like this...
> >
> >
> > appname1 leadername1 2005, 02, 02 2006, 02, 02
> > appname2 leadername2 2006, 03, 21 2007, 06, 28
> >
> > etc...
> >
> > The error message looks like this....
> >
> > back (most recent call last):
> > File "/home/amy/Documents/LIS452/assignment 3/testworks.py", line
> > 97, in <module>
> > main()
> > File "/home/amy/Documents/LIS452/assignment 3/testworks.py", line
> > 80, in main
> > a = Leaderapplicant(line) #from data file
> > File "/home/amy/Documents/LIS452/assignment 3/testworks.py", line 9,
> > in __init__
> > appname, leadername, start, end = line.split("\t")
> > ValueError: need more than 3 values to unpack
> >
> > Any help would be greatly appreciated. I have spent so much time on
> > this that I am behind not only in this class but in other classes as
> > well.
> >
>
>
> Immediately before line 9 put the following line:
>
> print line.split("\t")
>
> Now run it again and see how many values are in the list that is
> printed. Your code expects that there will be exactly four.
>
More information about the Python-list
mailing list