On 19Aug2014 16:41, Terry--gmail <terry.kemme...@gmail.com> wrote:
Alan Guald:

I have been trying out the different ways you suggested for doing this, and have ran into a problem on making the very last one work. I stuck a print statement in it to help, but I am not sure what the error statement is telling me:

for row in catalog2:
   print(row)
   for col, item in row:
       lens[col].append(len(item))
lens = [max(col) for col in lens]

and I get the following error in 'for col, item in row:'

'ValueError: too many values to unpack (expected 2)':

I don't see why it would possibly say there are too many values to unpack or why it would expect only 2!

Your for-loop says:

  for col, item in row:

That iterates over each element in "row" and attempts to unpack it into the two variables "col" and "item". Presumably the row element has more than two items in it. We'd need to see to say.

Try this:

   for element in row:
       print(element)
       col, item = element
       lens[col].append(len(item))

and see what you get.

Cheers,
Cameron Simpson <c...@zip.com.au>

Archiving the net is like washing toilet paper! - Leader Kibo
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to