[SciPy-user] help with list comprehensions
Wed Aug 1 13:58:05 CDT 2007
On 8/1/07, Stephen Yang <firstname.lastname@example.org> wrote:
> Hello everyone,
> I have a question about list comprehensions. I would like to append data
> to an existing list using a list comprehension. Unfortunately, what I
> have tried does not seem to work:
> >>> y = [5, 1, 3, 5]
> >>> x = ['a', 'b']
> >>> new = [x.append(data) for data in y]
> >>> new
> [None, None, None, None]
Since x.append(data) returns None.
And x at this point will be ['a', 'b', 5, 1, 3, 5]
I'm not sure what you're trying to achieve here, and why x.extend(y)
or new=x+y isn't sufficient, so perhaps if you explained your problem
in more depth?
I've got a gmail account. Why haven't I become cool?
More information about the SciPy-user