On Aug 20, 2014 12:07 PM, "Terry--gmail" <terry.kemme...@gmail.com> wrote: > > Alan Gauld > > Hi! > We are not quite out of the woods on this last example you gave me. It now seems to be complaining > that it doesn't want to append an integer to the list or that this isn't the place to use '.append' -- I am probably interpreting it's complaint wrong: > > Python 3.3 > > If I run this last piece of code that we just added 'enumerate(row)' to: > > lens = [0] * len(catalog2[0]) > for row in catalog2: > > for col, item in enumerate(row): > print(col, item, len(item)) > > lens[col].append(len(item)) > lens = [max(col) for col in lens] > > My result is: > > 0 Drives 6 <<---- my print statement result > > Traceback (most recent call last): > File "/home/justme/1a_Computer_Related/Python/scripts/scratch.py", line 43, in <module> > lens[col].append(len(item)) > AttributeError: 'int' object has no attribute 'append' > Once again you're confusing the list with its contents. lens is a list; lens[col] is an integer. lens.append(whatever) should do the trick.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor