A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/095101.html below:

using lambda to print everything in a list

using lambda to print everything in a list using lambda to print everything in a listJeff Shipman shippy at nmt.edu
Thu Apr 26 20:26:17 EDT 2001
I've started to discover the real handiness with
lambda expressions in python. I would like to
print out each string in a list without having
a for loop and I thought this was the perfect
candidate for lambda. This is what I'm doing:

map(lambda x: print x, ['line one', 'line two'])

and I get the following error:

  File "<stdin>", line 1
    map(lambda x: print x, ['line one', 'line two'])
                      ^
SyntaxError: invalid syntax

I can do it fine with things like string.replace, but
for some reason does it not like built-in functions?
Is there a way to do what I'm wanting to do? Or must
I use a for loop?

Thanks in advance,
 
Jeff "Shippy" Shipman     E-Mail: shippy at nmt.edu
Computer Science Major    ICQ: 1786493
New Mexico Institute of Mining and Technology
Homepage: http://www.nmt.edu/~shippy

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4