list comprehension question

Tripp Scott tripps81 at yahoo.com
Sun Mar 24 00:00:39 EST 2002


can i generate this list:

  [1, 1.1, 2, 2.1, 3, 3.1]

with a list comprehension in a form of this:

  [SOMETHING for x in 1,2,3]

and without using side effects like this?

  result=[]
  [(result.append(x), result.append(x+1.1)) for x in 1,2,3]

because the latter case is not very elegant to me.

t





More information about the Python-list mailing list