On 19Aug2014 16:41, Terry--gmail <terry.kemme...@gmail.com> wrote:
Alan Guald:
[...]
lens = [max(col) for col in lens]
[...]
Also, the list comprehension you have used on the final line reminds me that I would really like to understand comprehensions better. Is there some info on the Internet that starts very basic concerning comprehensions and explains step by step in complexity how they are structured and what the computer is doing?

The line above is essentially equivalent to this:

  lens_orig = lens
  lens = []
  for col in lens_orig:
    lens.append(max(col))

It just assembles a list of values, each being max(col), for each element in lens. The mucking with "lens" and "lens_orig" above is only because you're replacing "lens" with the new list.

Just looking at the code setting there inside the list brackets and know what the output is going to be, reminds me of a programmed cell of a spreadsheet....kind of.

It is very like that, if you consider two spreadsheet columns, the first with the original values in "lens" and the second having "max(col)" for each.

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

ERROR 155 - You can't do that.  - Data General S200 Fortran error code list
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to