On 20/01/2014 01:16, Doug and Riekie Dorman wrote:
I think I may have found a bug:
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')]
Should be:
pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
pairs.sort(key=lambda pairs: pairs[1])
pairs
[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]
I have increased the size of the two s's to show the problem.
Doug
What has the name you've given your lambda parameter got to do with the
name of your list?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor