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]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to