X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=norms.py;h=66452940c376658e446bb704c7198ee1ace2be22;hb=2e77bc75c34ac7d99310c1b778df972769068d98;hp=b8e4bf1ef82c8b8ea6f85c0e3c3597d90b7d9b8b;hpb=34ba3d687eb48af30929b4550f14d1a599179efd;p=cipher-training.git diff --git a/norms.py b/norms.py index b8e4bf1..6645294 100644 --- a/norms.py +++ b/norms.py @@ -13,7 +13,7 @@ def normalise(frequencies): >>> sorted(normalise({1: 1, 2: 2, 3: 1}).items()) [(1, 0.25), (2, 0.5), (3, 0.25)] """ - length = sum([f for f in frequencies.values()]) + length = sum(f for f in frequencies.values()) return collections.defaultdict(int, ((k, v / length) for (k, v) in frequencies.items()))