[Tutor] list comprehension equivalent to map(function, list item)

Bo Morris crushed26 at gmail.com
Sat Dec 14 02:03:57 CET 2013


i have the following simple function that iterates over the list. It passes
the list item into the function and adds the numbers. What would be the
equivalent way of writing the "map" portion with list comprehension? My
code is as follows:

def add(number):
    print 1 + int(number)



x = ['2', '4', '6', '8', '10', '12']

map(add, x)

thanks for the help and thank you for this mailing list.

AngryNinja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131213/91825071/attachment.html>


More information about the Tutor mailing list