cell and row

Jan Niestadt jan.niestadt at gmail.com
Tue Oct 25 07:40:14 EDT 2005


Because you're inserting items into your existing list instead of a new
list. What you probably mean is:

  b = []
  for x in a:
      b.append(x)

which creates a new list b that contains all elements whose length is
greater than four.
A better way to write this would be:

  b = [x for x in a if len(x) > 4]




More information about the Python-list mailing list