counts = defaultdict(int)
for currChar in records['ABC'].values():
counts[currChar] += 1
ks = [ct for k, ct in sorted(counts.items(), key=lambda x: x[1], reverse=True)]
Here I am not following the last line:
1) ct for k
What does this mean? What does k stand for? This is also the first use of variable ct and k in the code. Does ct represent count? What does k represent?
2) ct in sorted(counts.items(), key=lambda x: x[1], reverse=True) What is the meaning of above syntax especially key=lambda x: x[1] Again the code has not declared x variable anywhere in the codebase before its use here.