- See Difference in
for key in d.keys()
andfor key in d
- On underscores in Python
- Assigning more vars to same value
- Various ways, different in speed and in preserving the order, to uniquify a list: here and a followup with another suggestion (f7) here
- Various ways, with time benchmarks, to check if key is in dict, here
import site
site.getsitepackages()
d[k] = d.get(k, 0) + 1
You get a sorted representation, the dict is not actually sorted
s = sorted(d.items(), key=operator.itemgetter(0))
This gives list of tuples sorted by key.
max(day_numtweets, key=lambda x: x[1])