Instead of:
tot = x + y
Better: sum_ = x + y
And I can't see nothing wrong with: freqs = {}
for c in "abracadabra":
try:
freqs[c] += 1
except KeyError:
freqs[c] = 1
Or: nested = [[1, 2, 3], [4], [5, 6]]
flattened = sum(nested, [])
It is worth to mention dict.setdefault(): indices = {}
for i, c in enumerate("abracadabra"):
indices.setdefault(c, []).append(i)