Oct-12-2016, 02:32 AM
Hi,
I have the following code:
1) What does "t" here references?
I assume that "t" references tallyDict.items(). the square brackets in t[1] seems referencing list but type(tallyDict.items()), I got <class 'dict_items'>. So I'm a little confused here what "t" references.
2) Is there a technique that I could use to figure out myself what "t" in this lambda function references?
Thank you!
I have the following code:
from collections import OrderedDict tallyDict = {'New York': 12, 'Boston': 32, 'Atlanta': 5, 'Los Angeles': 16, 'Miami': 21} tallySorted = OrderedDict(sorted(tallyDict.items(), key=lambda t: t[1], reverse=True))the part key=lambda t: t[1].
1) What does "t" here references?
I assume that "t" references tallyDict.items(). the square brackets in t[1] seems referencing list but type(tallyDict.items()), I got <class 'dict_items'>. So I'm a little confused here what "t" references.
2) Is there a technique that I could use to figure out myself what "t" in this lambda function references?
Thank you!