Python Forum
Why my lambda doesn't work properly?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why my lambda doesn't work properly?
#3
I tried to understand this part from Python tutorial about passing lambdas as an argument.

4.7.6. Lambda Expressions
...

The above example uses a lambda expression to return a function. Another use is to pass a small function as an argument:
>>>

>>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
>>> pairs.sort(key=lambda pair: pair[1])
>>> pairs
[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]
Reply


Messages In This Thread
Why my lambda doesn't work properly? - by Snake - Mar-11-2020, 04:42 AM
RE: Why my lambda doesn't work properly? - by Snake - Mar-11-2020, 05:43 AM
RE: Why my lambda doesn't work properly? - by Snake - Mar-11-2020, 07:57 AM
RE: Why my lambda doesn't work properly? - by Snake - Mar-29-2020, 04:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extending list doesn't work as expected mmhmjanssen 2 185 May-09-2024, 05:39 PM
Last Post: Pedroski55
  Why doesn't calling a parent constructor work with arbitrary keyword arguments? PurposefulCoder 4 999 Jun-24-2023, 02:14 PM
Last Post: deanhystad
  While Loop Does Not Work Properly mactron 4 975 Jun-22-2023, 01:04 AM
Last Post: mactron
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,896 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 937 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  client.get_all_tickers() Doesn't work gerald 2 1,757 Jun-16-2022, 07:59 AM
Last Post: gerald
  pip doesn't work after Python upgrade Pavel_47 10 4,309 May-30-2022, 03:31 PM
Last Post: bowlofred
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 2,068 Dec-18-2021, 02:38 AM
Last Post: knight2000
  Class Method to Calculate Age Doesn't Work gdbengo 1 1,739 Oct-30-2021, 11:20 PM
Last Post: Yoriz
  Process doesn't work but Thread work ! mr_byte31 4 2,680 Oct-18-2021, 06:29 PM
Last Post: mr_byte31

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020