Talk:Python Programming/Lists

Slices
It seems to be that all of the discussion on indexing/slicing should be in one place. Right now the discussion is split rather awkwardly between here and the strings section. Within the list section we can just cover slice/index assignment. --Artevelde 09:27, 26 October 2005 (UTC)

Length of a list
Nice work, but how about a paragraph about len(list), max(list), min(a)

Why so few programming examples?
Almost all of the Python example code is shown as code that is generated from the interactive interpreter, but things that work there do not work in a Python script. For instance, from the Python documentation:

But if one enters the word  on a line by itself in a script, you do not get output, you get a syntax error. Now you can use print to output the set fruit, but how do you use  for finer-grained control of output?

Programming examples would be a tremendous help, and more apt to be relevant to what the reader is trying to accomplish than command line examples.

Code examples use the reserved word list
The use of the reserved word list is not really recommended. Is it not better to change the variable names from "list" into "alist"? Ploffie (discuss • contribs) 09:34, 18 December 2011 (UTC)

Multiple 'for's in a list comprehension
"It will evaluate the items in all of the objects sequentially and will loop over the shorter objects if one object is longer than the rest."

This statement doesn't make any sense. Multiple fors in a list comprehension behave as if they are nested loops; in the example, 'pot' is looped over simply because it is the inner loop. Changing the order of the statements would cause 'flower' to be looped over instead even though it is larger.

It would be more correct to describe the behavior of the example as being equivalent to the following: Harbinger0x7c0 (discuss • contribs) 18:42, 23 January 2012 (UTC)