[SciPy-user] help with list comprehensions
Wed Aug 1 13:53:21 CDT 2007
list comprehension creates a new list with the return of a function. Here,
w.append(data) returns None, so you have a list of None.
More simple :
>>> x + y
2007/8/1, Stephen Yang <email@example.com>:
> 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]
> Can anyone help? Thanks very much in advance.
> SciPy-user mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user