I am new to python. I have a few questions coming from an armature!
Lawrence D’Oliveiro
lawrencedo99 at gmail.com
Tue Aug 16 02:28:22 EDT 2016
On Tuesday, August 16, 2016 at 6:26:01 PM UTC+12, Paul Rudin wrote:
> sohcahtoa82 writes:
>> squared_plus_one_list = map(lambda x: x**2 + 1, some_list)
>
> I realise that this is about understanding lambda, but it's worth noting
> in passing that we tend to write this sort of thing as:
>
> squared_plus_one_list = [x**2 + 1 for x in some_list]
The difference being that the “map” function takes an iterable and returns an iterator.
Why could this difference be important?
More information about the Python-list
mailing list